I am looking for more examples that compile under both C (any standard) and C++, but run differently. As an example, I found this in comp.lang.c, which produces 8 for C, and 512 for C++:
#include <stdio.h>
struct A { char block[8]; };
int main(void) {
struct B {
struct A {
char block[512];
} a;
};
printf("sizeof(struct A) = %lu\n",
(unsigned long) sizeof(struct A));
return 0;
}
Does anyone have any more examples of this, especially ones not using this particular trick?