You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The vendored catch.h header in the testthat package references std::uncaught_exception, which has been deprecated in C++17 and removed in C++20. When compiling with clang++-20 and the -std=gnu++20 flag, this leads to a compilation error:
clang++-20 -stdlib=libc++ -std=gnu++20 -I"/opt/R/devel/lib/R/include" -DNDEBUG -I'/github/home/R/x86_64-pc-linux-gnu-library/4.5/Rcpp/include' -I'/github/home/R/x86_64-pc-linux-gnu-library/4.5/RcppThread/include' -I'/github/home/R/x86_64-pc-linux-gnu-library/4.5/progress/include' -I'/github/home/R/x86_64-pc-linux-gnu-library/4.5/spacefillr/include' -I'/github/home/R/x86_64-pc-linux-gnu-library/4.5/testthat/include' -I/usr/local/include -D RAY_REPRODUCE_PERLIN -DSTRICT_R_HEADERS -DRAY_HAS_X11 -DHAS_SSE -DHAS_SSE2 -DRAYSIMD -DRAYSIMDVECOFF -fpic -O3 -Wall -pedantic -frtti -Wp,-D_FORTIFY_SOURCE=3 -Wall -pedantic -c test-runner.cpp -o test-runner.o
In file included from test-runner.cpp:7:
In file included from /github/home/R/x86_64-pc-linux-gnu-library/4.5/testthat/include/testthat.h:1:
In file included from /github/home/R/x86_64-pc-linux-gnu-library/4.5/testthat/include/testthat/testthat.h:72:
/github/home/R/x86_64-pc-linux-gnu-library/4.5/testthat/include/testthat/vendor/catch.h:8382:20: error: no member named 'uncaught_exception' in namespace 'std'; did you mean 'uncaught_exceptions'?
8382 | if ( !std::uncaught_exception() ){
| ~~~~~^
/usr/lib/llvm-20/bin/../include/c++/v1/__exception/operations.h:35:31: note: 'uncaught_exceptions' declared here
35 | _LIBCPP_EXPORTED_FROM_ABI int uncaught_exceptions() _NOEXCEPT;
| ^
In file included from test-runner.cpp:7:
In file included from /github/home/R/x86_64-pc-linux-gnu-library/4.5/testthat/include/testthat.h:1:
In file included from /github/home/R/x86_64-pc-linux-gnu-library/4.5/testthat/include/testthat/testthat.h:72:
/github/home/R/x86_64-pc-linux-gnu-library/4.5/testthat/include/testthat/vendor/catch.h:8705:22: error: no member named 'uncaught_exception' in namespace 'std'; did you mean 'uncaught_exceptions'?
8705 | if( std::uncaught_exception() )
| ~~~~~^
/usr/lib/llvm-20/bin/../include/c++/v1/__exception/operations.h:35:31: note: 'uncaught_exceptions' declared here
35 | _LIBCPP_EXPORTED_FROM_ABI int uncaught_exceptions() _NOEXCEPT;
| ^
2 errors generated.
make: *** [/opt/R/devel/lib/R/etc/Makeconf:204: test-runner.o] Error 1
ERROR: compilation failed for package ‘rayrender’
* removing ‘/tmp/Rtmp5ZqS0O/pkg-lib2ec7db28e4f/rayrender’
This issue arises in two locations in catch.h:
Line 8382: if ( !std::uncaught_exception() ){
Line 8705: if( std::uncaught_exception() )
This error was detected by compiling the rayrender package with the rhub clang20 runner.
I have updated my package to temporarily remove compiled tests by wrapping all calls to Catch2 functions and <testthat.h> (which includes the deprecated C++20 function) in a preprocessor guard.
However, because testthat includes the following dummy function to ensure the symbol is registered:
# This dummy function definition is included with the package to ensure that# 'tools::package_native_routine_registration_skeleton()' generates the required# registration info for the 'run_testthat_tests' symbol.
(function() {
.Call("run_testthat_tests", FALSE, PACKAGE="rayrender")
})
I had failures due to it trying to I needed to resolve the run_testthat_tests symbol, which it couldn't because I had to add a guard to test-runner.cpp to prevent it from including <testthat.h> (which contains the symbol R was looking for). So I had to also include a dummy function so that that symbol would resolve as well.
/* * Please do not edit this file -- it ensures that your package will export a * 'run_testthat_tests()' C routine that can be used to run the Catch unit tests * available in your package.*/
#ifdef NOT_CRAN
#defineTESTTHAT_TEST_RUNNER
#include<testthat.h>
#else
#include<R.h>
#include<Rinternals.h>extern"C" SEXP run_testthat_tests(SEXP use_xml_sxp) {
returnRf_ScalarLogical(true);
}
#endif
Description
The vendored catch.h header in the testthat package references
std::uncaught_exception
, which has been deprecated in C++17 and removed in C++20. When compiling with clang++-20 and the -std=gnu++20 flag, this leads to a compilation error:This issue arises in two locations in catch.h:
if ( !std::uncaught_exception() ){
if( std::uncaught_exception() )
This error was detected by compiling the rayrender package with the rhub clang20 runner.
https://github.com/tylermorganwall/rayrender/actions/runs/12653086666/job/35257420480
Suggested Fix
Replace the calls to
std::uncaught_exception()
withstd::uncaught_exceptions() > 0
, which is the recommended replacement in C++17 and later.Here’s the updated code:
and
The text was updated successfully, but these errors were encountered: