Opened 6 years ago

Last modified 5 years ago

#57578 closed defect

__has_feature(cxx_exceptions) returns true but fails to compile std::uncaught_exceptions() — at Version 3

Reported by: noloader (Jeffrey Walton) Owned by:
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc:
Port: clang-6.0

Description (last modified by noloader (Jeffrey Walton))

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

I don't know the Macport version and I can't find the method searching ("macport version command line"). "port --version" and "port -V" does not return it.

Change History (3)

comment:1 Changed 6 years ago by noloader (Jeffrey Walton)

Description: modified (diff)

comment:2 Changed 6 years ago by noloader (Jeffrey Walton)

Description: modified (diff)

comment:3 Changed 6 years ago by noloader (Jeffrey Walton)

Description: modified (diff)
Note: See TracTickets for help on using tickets.