catchorg / Catch2

A modern, C++-native, test framework for unit-tests, TDD and BDD - using C++14, C++17 and later (C++11 support is in v2.x branch, and C++03 on the Catch1.x branch)
https://discord.gg/4CWS9zD
Boost Software License 1.0
18.58k stars 3.05k forks source link

Bus error when Catch2 tries catching an exception when using Clang 19 #2913

Open quantheory opened 2 weeks ago

quantheory commented 2 weeks ago

Describe the bug When Catch2 catches an exception thrown by test code in Clang 19.1 (at least the version I have installed using homebrew on my Mac), it results in a Bus error: 10. This occurs regardless of whether or not the exception is raised inside a REQUIRE macro, so long as the exception is caught by Catch2. (If I set up a try block to catch the exception myself before any Catch2 code sees it, it doesn't seem to cause a problem.)

Expected behavior Catch2 should catch the exception and produce some kind of reasonable output. If in a REQUIRE_THROWS macro where an appropriate exception is raised, the test should pass.

Reproduction steps This test file was enough to trigger the problem for me:

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

TEST_CASE( "blah", "blah" ) {

  SECTION( "blah" ) {
    throw(std::runtime_error("Hi"));
  }

}

I typically get output like this:

Randomness seeded to: 638767569
Bus error: 10

Platform information:

quantheory commented 2 weeks ago

I should note that I'm not positive whether this is really a Catch2 error, or an issue with the particular Clang installation I have. It would be nice to know if anyone else can reproduce the issue.