[llvm-bugs] [Bug 39631] New: __has_feature(cxx_exceptions) returns true but fails to compile std::uncaught_exceptions()
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Nov 11 14:05:07 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=39631
Bug ID: 39631
Summary: __has_feature(cxx_exceptions) returns true but fails
to compile std::uncaught_exceptions()
Product: clang
Version: 6.0
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: C++'17
Assignee: unassignedclangbugs at nondot.org
Reporter: noloader at gmail.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
I'm testing C+_17 on OS X 10.8.5 and 10.9.5 using Macports compilers versions
5.0 and 6.0. Attempting to compile the following program:
$ cat test.cxx
#if __EXCEPTIONS && __has_feature(cxx_exceptions)
# include <exception>
# define CXX17_EXCEPTIONS 1
#endif
void Foo()
{
#if defined(CXX17_EXCEPTIONS)
if (std::uncaught_exceptions() == 0)
#endif
{
int x = 0;
}
}
Results in:
$ /opt/local/bin/clang++-mp-5.0 -std=gnu++17 test.cxx -c
test.cxx:9:14: error: 'uncaught_exceptions' is unavailable: introduced in macOS
10.12
if (std::uncaught_exceptions() == 0)
^
/opt/local/libexec/llvm-5.0/include/c++/v1/exception:130:63: note:
'uncaught_exceptions' has been explicitly marked unavailable here
_LIBCPP_FUNC_VIS _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS int uncaught_e...
^
1 error generated.
According to the LLVM 3.6 release notes
(https://releases.llvm.org/3.6.0/tools/clang/docs/ReleaseNotes.html#the-exceptions-macro),
I believe I am using the correct feature test:
To reliably test if C++ exceptions are enabled,
use __EXCEPTIONS && __has_feature(cxx_exceptions),
else things won’t work in all versions of Clang in
Objective-C++ files.
==========
$ /opt/local/bin/clang++-mp-6.0 --version
clang version 6.0.1 (tags/RELEASE_601/final)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-6.0/bin
$ /opt/local/bin/clang++-mp-5.0 --version
clang version 5.0.2 (tags/RELEASE_502/final)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-5.0/bin
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.9.5
BuildVersion: 13F1911
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181111/f3c8c9f0/attachment.html>
More information about the llvm-bugs
mailing list