With the compiler I tested against (gcc 4.8.4), the value is set to zero (for the 'abc' input) regardless of which version of the standard I compile against. Note also that it is set to minimum/maximum values if you provide a valid integer that is outside of the supported range of the variable that you are assigning to.
A more important point though, is that ignoring error flags is a recipe for disaster. Once you have an error in the input, any subsequent input is suspect (without hacks like ignore()). Situations like this are a good candidate for using exception handling.
Here's how I might implement what you are trying to do (but, again, considering the case of multiple inputs, recovering from errors is a messy business):
cin.exceptions( ~std::ios::goodbit );
try { cin >> age; }
catch ( std::ios::failure const & )
{
age=-1;
cin.clear();
cin.ignore(999,'\n');
}
or without exeptions:
cin >> age;
if ( cin.fail() ) age=-1, cin.clear(), cin.ignore(999,'\n');
See here for similar questions:
- Why does stringstream >> change value of target on failure?
- istream behavior change in C++ upon failure
Here are up-to-date docs for the operator in question:
- http://www.cplusplus.com/reference/istream/istream/operator%3E%3E/
- http://en.cppreference.com/w/cpp/io/basic_istream/operator_gtgt