Twisted C++ code -
possible duplicate: undefined behavior , sequence points
#include< iostream.h> int main() { int i=7,j=i; j=(i++,++i,j++*i); cout <<j; return 0; }
what output of c++ code?
it's homework professor gave me.
it helps convince people don't believe undefined compiling program several compilers , observing results:
after fixing iostream.h
error,
- g++ 4.5.2 prints 64
- clang++ 2.8 prints 63
- sun c++ 5.8 prints 63
- msvc 2010 prints 64
(oh, and, re-written use c i/o, original k&r c compiler on unix 7 prints 63)
Comments
Post a Comment