What are examples of syntax that is valid in both C and C++ but has different semantics? Put another way, what are examples of programs that produce different output when compiled with C and C++ compilers?
Asked
Active
Viewed 226 times
1 Answers
1
sizeof('c')
— 1 in C++, same assizeof(int)
in C.

Jonathan Leffler
- 730,956
- 141
- 904
- 1,278
-
That's not guaranteed to be different :-( – Kerrek SB Jan 19 '14 at 23:40
-
@KerrekSB: For those few systems where `sizeof(int) == sizeof(char)`, which necessitates `CHAR_BITS > 8`. – Jonathan Leffler Jan 19 '14 at 23:57