[cfe-users] Failed formatted input using std::istream

Dmitri Shubin sbn at tbricks.com
Tue May 7 07:35:29 PDT 2013


For the following small test I got different result when using clang w/ 
libstdc++ and libc++:

#include <sstream>
#include <iostream>

int main()
     std::istringstream iss("-a");
     unsigned i = 12345;
     iss >> i;
     std::cout << i << std::endl;
     return 0;

$ clang++ a.cpp
$ ./a.out
$ clang++ -stdlib=libc++ a.cpp
$ ./a.out
$ clang -v
Apple LLVM version 4.2 (clang-425.0.27) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.3.0
Thread model: posix

If my understanding of the C++ standard (C++03) is correct libstdc++ is 
right here, since [lib.facet.num.get.virtuals] says
"If an error occurs, val is unchanged; otherwise it is set to the 
resulting value."

Or am I missing something and I shouldn't count on particular result here?


More information about the cfe-users mailing list