[cfe-dev] Odd clang result using stringstream formatted input
Edward Diener via cfe-dev
cfe-dev at lists.llvm.org
Thu Oct 27 02:41:12 PDT 2016
The following program:
#include <iostream>
#include <sstream>
#include <stdexcept>
int main()
{
std::stringstream ss;
ss.exceptions(std::ios_base::failbit | std::ios_base::badbit);
char c;
try
{
ss >> c;
std::cout << "Exception not thrown.";
}
catch (std::runtime_error &)
{
std::cout << "Exception std::runtime_error thrown.";
}
catch (...)
{
std::cout << "Unknown exception thrown.";
}
}
outputs "Unknown exception thrown." when compiled and linked with the
latest clang built from source on Windows 7. The compilation options are:
-c -x c++ -Wno-unused-local-typedef -Wno-dll-attribute-on-redeclaration
-O0 -g -fno-inline -Wall -g -march=i686 -m32 -o
The linker options are:
-Wl,-Bstatic -Wl,-Bdynamic -Wl,--end-group -g -march=i686 -m32
I would have expected the output to be "Exception std::runtime_error
thrown." as it is when compiled with VC++ 14.
Is clang following the C++ standard or is this a bug in clang ?
More information about the cfe-dev
mailing list