Skip to content

doesn't compile with newer clang #2227

@hoeflerb

Description

@hoeflerb

When running install.packages('testthat') with a recent Clang:

* installing *source* package ‘testthat’ ...
** this is package ‘testthat’ version ‘3.2.3’
** package ‘testthat’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
using C compiler: ‘Homebrew clang version 21.1.0’
using C++ compiler: ‘Homebrew clang version 21.1.0’
using SDK: ‘MacOSX15.2.sdk’

<snip>

/opt/homebrew/opt/llvm/bin/clang++ -I"/opt/homebrew/Cellar/r/4.5.1/lib/R/include" -DNDEBUG -I../inst/include -DCOMPILING_TESTTHAT  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/include -I/opt/homebrew/opt/llvm/include -I/opt/homebrew/opt/openssl/include -I/opt/homebrew/opt/gettext/include	-I/opt/homebrew/opt/tcl-tk/include -DCATCH_CONFIG_CPP11_NO_SHUFFLE -Wno-missing-template-arg-list-after-template-kw    -fPIC  -g -O3 -Wall -pedantic -mtune=native -pipe  -c test-runner.cpp -o test-runner.o
In file included from test-runner.cpp:7:
In file included from ../inst/include/testthat.h:1:
In file included from ../inst/include/testthat/testthat.h:72:
../inst/include/testthat/vendor/catch.h:7187:18: error: no member named 'random_shuffle' in namespace 'std'
 7187 |             std::random_shuffle( vector.begin(), vector.end() );
      |                  ^~~~~~~~~~~~~~
In file included from test-runner.cpp:7:
In file included from ../inst/include/testthat.h:1:
In file included from ../inst/include/testthat/testthat.h:170:
In file included from /opt/homebrew/Cellar/r/4.5.1/lib/R/include/R.h:70:
/opt/homebrew/Cellar/r/4.5.1/lib/R/include/R_ext/Boolean.h:62:36: warning: unknown warning group '-Wfixed-enum-extension', ignored [-Wunknown-warning-option]
   62 | #  pragma clang diagnostic ignored "-Wfixed-enum-extension"
      |                                    ^
1 warning and 1 error generated.
make: *** [test-runner.o] Error 1
ERROR: compilation failed for package ‘testthat’
* removing ‘/opt/homebrew/lib/R/4.5/site-library/testthat’

According to this, std::random_shuffle was deprecated in C++14 and removed in C++17, and C++17 is the default standard for Clang versions 16 and higher.

I can make this build by forcing C++14 in my Makevars file, but it would be great if this can be fixed at the source.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions