#include <sstream> #include <stdexcept> int func() { std::string s; throw std::invalid_argument( s ); }
g++-4.3.0 -std=c++0x test.cpp test.cpp: In function 'int func()': test.cpp:7: error: 'invalid_argument' cannot be used as a function this code compiles only, if -std=c++0x is not given. If you just include <string> instead of <sstream>, it also works with -std=c++0x, so it seems to be related to the declarations in sstream, but i couldn't manage to dig deeper. I tried to reduce the preprocessed source using delta/topformflat, but it kicked out the declaration of invalid_argument giving me the same error. Strangely using a smililar type like domain_error or out_of_range (they have the same base-class and their only definition is the constructor) works too. gcc version 4.3.0 20071213 (experimental) (GCC) -- Summary: combination of sstream, invalid_argument and -std=c++0x breaks valid code Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: rbuergel at web dot de http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34538