[MacPorts] #57578: __has_feature(cxx_exceptions) returns true but fails to compile std::uncaught_exceptions()
MacPorts
noreply at macports.org
Sun Nov 11 22:23:01 UTC 2018
#57578: __has_feature(cxx_exceptions) returns true but fails to compile
std::uncaught_exceptions()
-------------------------------------------------+-------------------------
Reporter: noloader | Owner: (none)
Type: defect | Status: new
Priority: Normal | Milestone:
Component: ports | Version:
Keywords: C++17 cxx_exceptions | Port:
std::uncaught_exceptions() | clang++-mp-6.0
-------------------------------------------------+-------------------------
I'm testing C++17 on OS X 10.8.5 and 10.9.5 using Macports Clang compiler
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...
^
-std=c++17 produces the same error.
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.
==========
Upstream issue report at https://bugs.llvm.org/show_bug.cgi?id=39631
==========
$ /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
--
Ticket URL: <https://trac.macports.org/ticket/57578>
MacPorts <https://www.macports.org/>
Ports system for macOS
More information about the macports-tickets
mailing list