I know that at least one of the changes in C++11 that will cause some old code to stop compiling: the introduction of explicit operator bool() in the standard l
Stream extraction failure is treated differently.
#include
#include
int main()
{
std::stringstream ss;
ss << '!';
int x = -1;
assert(!(ss >> x)); // C++03 and C++11
assert(x == -1); // C++03
assert(x == 0); // C++11
}
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3246.html#23
[C++03: 22.2.2.1.2/11]:The result of stage 2 processing can be one of
- A sequence of chars has been accumulated in stage 2 that is converted (according to the rules of
scanf) to a value of the type ofval. This value is stored invalandios_base::goodbitis stored inerr.- The sequence of chars accumulated in stage 2 would have caused
scanfto report an input failure.ios_base::failbitis assigned toerr. [ed: Nothing is stored inval.]
[C++11: 22.4.2.1.2/3]:[..] The numeric value to be stored can be one of:
- zero, if the conversion function fails to convert the entire field.
ios_base::failbitis assigned toerr.- the most positive representable value, if the field represents a value too large positive to be represented in
val.ios_base::failbitis assigned toerr.- the most negative representable value or zero for an unsigned integer type, if the field represents a value too large negative to be represented in
val.ios_base::failbitis assigned toerr.- the converted value, otherwise.
The resultant numeric value is stored in
val.
GCC 4.8 correctly outputs for C++11:
Assertion `x == -1' failed
GCC 4.5-4.8 all output for C++03 the following, which would appear to be a bug:
Assertion `x == -1' failed
Visual C++ 2008 Express correctly outputs for C++03:
Assertion failed: x == 0
Visual C++ 2012 Express incorrectly outputs for C++11, which would appear to be a status-of-implementation issue:
Assertion failed: x == 0