[cfe-dev] Odd clang result using stringstream formatted input

Reid Kleckner via cfe-dev cfe-dev at lists.llvm.org
Mon Oct 31 10:05:25 PDT 2016


Seems like a mingw-ish bug. This program works as expected in an MSVC
environment. I don't have a 32-bit mingw installation to reproduce your
configuration.

On Thu, Oct 27, 2016 at 2:41 AM, Edward Diener via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> 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 ?
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161031/431baf49/attachment.html>


More information about the cfe-dev mailing list