From: Tomasz KamiƄski Date: Tue, 14 Apr 2026 12:31:24 +0000 (+0200) Subject: libstdc++: Fix constant_wrapper compile-time test for COW strings. X-Git-Tag: basepoints/gcc-17~200 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ffbf69999b1a0e49362aa4c687eb176675a2e53;p=thirdparty%2Fgcc.git libstdc++: Fix constant_wrapper compile-time test for COW strings. Throwing std::invalid_argument at compile time is only supported for SSO strings, replaced with custom class. libstdc++-v3/ChangeLog: * testsuite/20_util/constant_wrapper/generic.cc: Replace std::std::invalid_argument with NegativeArgument and removed include. --- diff --git a/libstdc++-v3/testsuite/20_util/constant_wrapper/generic.cc b/libstdc++-v3/testsuite/20_util/constant_wrapper/generic.cc index 7538efead49..bd41fc4ca3a 100644 --- a/libstdc++-v3/testsuite/20_util/constant_wrapper/generic.cc +++ b/libstdc++-v3/testsuite/20_util/constant_wrapper/generic.cc @@ -2,7 +2,6 @@ #include #include #include -#include #include @@ -172,13 +171,15 @@ struct MoveArgFunc { return arg.v; } }; +struct NegativeArgument {}; + struct ThrowFunc { static constexpr int operator()(int i, int j) { if (i < 0 || j < 0) - throw std::invalid_argument("negative"); + throw NegativeArgument(); return i + j; } }; @@ -249,7 +250,7 @@ test_function_object() try { std::cw(std::cw<-1>, std::cw<1>); VERIFY(false); - } catch (const std::invalid_argument&) { + } catch (const NegativeArgument&) { VERIFY(true); } } @@ -322,7 +323,7 @@ struct ThrowIndex operator[](int i, int j) { if (i < 0 || j < 0) - throw std::invalid_argument("negative"); + throw NegativeArgument(); return i * j; } }; @@ -391,7 +392,7 @@ test_indexable1() try { std::cw[std::cw<-1>, std::cw<1>]; VERIFY(false); - } catch (const std::invalid_argument&) { + } catch (const NegativeArgument&) { VERIFY(true); } }