I ran into this while compiling some portable code in gcc
. Basically this strange code compiles in Visual studio which really just blows my mind:
class Zebra {int x;};
Zebra goo() {Zebra z; return z;}
void foo(Zebra &x)
{
Zebra y;
x = y;
foo(goo());
}
Visual studio
lets this one fly. gcc
will catch this as a compile error. Interestingly, If you typedef Zebra to int, VC++
will complain. Quite contradictory behavior. Thoughts?
warning C4239: nonstandard extension used
, but apparently you have that warning turned off.