Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with Catch 2.2.0 on macos 10.11.6 and clang 5.0.1 #1218

Closed
aacirino opened this issue Mar 10, 2018 · 10 comments
Closed

Issues with Catch 2.2.0 on macos 10.11.6 and clang 5.0.1 #1218

aacirino opened this issue Mar 10, 2018 · 10 comments

Comments

@aacirino
Copy link

I hadn't updated my local Catch2 repo for a while and when I saw that v2.2.0 was available I pulled it, but then run into trouble. A test as simple as this

#define CATCH_CONFIG_MAIN
#include "catch2/catch.hpp"

TEST_CASE("Test issue") {
  auto test = true;
  REQUIRE(test == true);
}

gives the following errors:

/usr/local/include/catch2/catch.hpp:5787:62: error: no template named 'optional' in namespace 'std'
    inline auto convertInto( std::string const &source, std::optional<T>& target ) -> ParserResult {
                                                        ~~~~~^
/usr/local/include/catch2/catch.hpp:10770:21: error: 'uncaught_exceptions' is unavailable: introduced in macOS 10.12
        return std::uncaught_exceptions() > 0;
                    ^
/usr/local/Cellar/llvm/5.0.1/include/c++/v1/exception:130:63: note: 'uncaught_exceptions' has been explicitly marked unavailable here
_LIBCPP_FUNC_VIS _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS int uncaught_exceptions() _NOEXCEPT;

I had to revert to a commit in January to be able to keep using Catch 2. I tried several commits and stopped at 1ab6be3 as the working one.

@chronoxor
Copy link

Looks like the same - #1214

@chronoxor
Copy link

Travis config to reproduce the issue:

sudo: required
dist: trusty

os: linux
compiler: clang
env: OS=linux COMPILER=clang CLANG_VERSION=5.0

sources:
  - ubuntu-toolchain-r-test
  - llvm-toolchain-trusty-5.0

packages:
  - clang-5.0
  - libc++-dev
  - libc++abi-dev

before_install:
  - export CC="clang-${CLANG_VERSION}" CXX="clang++-${CLANG_VERSION}"
  - pushd .
  - git clone --depth=1 https://github.com/llvm-mirror/llvm.git llvm-source
  - git clone --depth=1 https://github.com/llvm-mirror/libcxx.git llvm-source/projects/libcxx
  - git clone --depth=1 https://github.com/llvm-mirror/libcxxabi.git llvm-source/projects/libcxxabi
  - mkdir llvm-build && cd llvm-build
  - cmake -DCMAKE_C_COMPILER=${CC} -DCMAKE_CXX_COMPILER=${CXX} -DCMAKE_INSTALL_PREFIX=/usr ../llvm-source
  - make cxx -j2
  - sudo make install-cxxabi install-cxx
  - popd

@horenmar
Copy link
Member

There are 2 bugs in this, one is already fixed as part of #1214, the second one is that OSX 10.11's Clang claims to support C++17 but does not provide std::uncaught_exceptions.

Quick google says that 10.12 has been released September 2016, may I suggest an update?

@aacirino
Copy link
Author

Better said then done. My MacBook is OK, but my desktop is too old to upgrade to 10.12 and it is my main development computer. I updated LLVM to 6.0 and got rid of the first issue ( error: no template named 'optional' in namespace 'std') but the uncaught_exceptions remains. It is weird, since I am not using Apple's stock LLVM installation and I am relying on LLVM installed by homebrew, that I thought would bring in the solution to this issue with its libc++.

@horenmar
Copy link
Member

Better said then done.

Fair enough. If I find someone who can tell me how to detect OS X versions properly, I can fix it, but that will have to wait a bit.

@aacirino
Copy link
Author

By inspecting LLVM's libraries it indeed seems that the only solution to be able to use C++17, Catch2 and macos is to upgrade to macos 10.12. For the moment I will fork Catch2 and change Catch's uncaught_exceptions to use the pre-C++17 version. I will also look for a way to detect macos version and circumvent the issue.

@chronoxor
Copy link

chronoxor commented Mar 11, 2018

Maybe this workaround will help you:

#ifdef __clang__
#define CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS
#endif

@aacirino
Copy link
Author

I've put #define CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS in my pre-compiled header and it worked fine with no need to change Catch2. I still haven't found a way to detect the macos version at compile time.

Thanx guys for your help.

@martinmoene
Copy link
Collaborator

Perhaps of interest:

Pre-2017 MSVC, GCC and Clang implementation of uncaught_exceptions() in PR 126 of gsl lite.

PR 126: Fix final_action_return and final_action_error during stack unwinding

@horenmar
Copy link
Member

horenmar commented May 9, 2020

The check was changed to use std feature macro, and allow user to override it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants