llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.37k stars 12.14k forks source link

Compiling with clang-cl with recommended exceptions turned off gives error in header file #18708

Open b1622bb8-0285-400e-ba44-ba0e5027e546 opened 10 years ago

b1622bb8-0285-400e-ba44-ba0e5027e546 commented 10 years ago
Bugzilla Link 18334
Version trunk
OS Windows XP
CC @DougGregor,@rnk
b1622bb8-0285-400e-ba44-ba0e5027e546 commented 10 years ago

I do not think that -EHs-c- is a valid sequence for the -EH option in VC++.

But whatever you do you need to support exception handling in clang-cl. Even if you only support handling of C++ exceptions only this is better than the problems that are occurring when you mandate that _HAS_EXCEPTIONS must be set to 0 in order to use clang-cl.

rnk commented 10 years ago

I think we may move to a mode like how MSVC operates with -EHs-c-, where it warns about ignored exception handlers and then drops them on the floor.

b1622bb8-0285-400e-ba44-ba0e5027e546 commented 10 years ago

I hit the wrong button and did not describe the bug, so here it is:

In file included from config_test.cpp:151:
In file included from ./boost_no_cxx11_hdr_future.ipp:13:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\future:18:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\ppltasks.h:21:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\ppl.h:19:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\concrt.h(4878,21) :  error: use of undeclared identifier '__uncaught_exception'; did you mean 'std::uncaught_exception'?
                if (!__uncaught_exception())

This error occurs because clang-cl is being compiled without exceptions by defining _HAS_EXCEPTIONS as 0. I have already reported ( https://connect.microsoft.com/VisualStudio/feedback/details/811347/compiling-vc-12-0-with-has-exceptions-0-and-including-concrt-h-causes-a-compiler-error ) this same error to Microsoft since it also occurs with VC++ when _HAS_EXCEPTIONS is 0.

Despite the fact that clang-cl wants to work with without exception handling support and therefore with _HAS_EXCEPTIONS set to 0, and despite the fact that Microsoft allowed at one time and still theoretically allows exception handling to be turned off by setting _HAS_EXCEPTIONS to 0, I do not think this is a viable strategy, even short term for clang-cl. In other words without support for exception handling I do not believe clang-cl is usable. This latest bug report, even though it also duplicates the same problem as VC++ when _HAS_EXCEPTIONS is 0, hopefully shows what I mean.