Skip to content

compiling under c++17 has warning about 'try' in constexpr #18

@JeffGarland

Description

@JeffGarland

Describe the deficiency


in c++17 mode there are warnings on gcc15 about 'try' in constexpr. Presumably this might be a hard error elsewhere. Note that this can be seen in the CI run as well.

jeff@ub25-04:~/dev/indirect/build$ cmake .. -DCMAKE_CXX_COMPILER=g++-15 -DCMAKE_CXX_STANDARD=17 -G=Ninja

Compilation started at Tue May  5 12:22:25

cd ~/dev/indirect/build; ninja -v -j 4
[1/10] /usr/bin/g++-15  -I/home/jeff/dev/indirect/include -I/home/jeff/dev/indirect/build/include -std=c++17 -MD -MT examples/CMakeFiles/beman.indirect.examples.polymorphic_basic.dir/polymorphic_basic.cpp.o -MF examples/CMakeFiles/beman.indirect.examples.polymorphic_basic.dir/polymorphic_basic.cpp.o.d -o examples/CMakeFiles/beman.indirect.examples.polymorphic_basic.dir/polymorphic_basic.cpp.o -c /home/jeff/dev/indirect/examples/polymorphic_basic.cpp
In file included from /home/jeff/dev/indirect/examples/polymorphic_basic.cpp:3:
/home/jeff/dev/indirect/include/beman/indirect/polymorphic.hpp: In member function ‘constexpr beman::indirect::detail::control_block<T, Allocator>* beman::indirect::detail::direct_control_block<T, U, Allocator>::clone(const Allocator&) const’:
/home/jeff/dev/indirect/include/beman/indirect/polymorphic.hpp:62:9: warning: ‘try’ in ‘constexpr’ function only available with ‘-std=c++20’ or ‘-std=gnu++20’ [-Wc++20-extensions]
   62 |         try {
      |         ^~~

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions