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?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…