https://gcc.gnu.org/g:2ffbf69999b1a0e49362aa4c687eb176675a2e53
commit r16-8604-g2ffbf69999b1a0e49362aa4c687eb176675a2e53
Author: Tomasz Kamiński <tkaminsk@redhat.com>
Date: Tue Apr 14 14:31:24 2026 +0200
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 <stdexcept> include.
Diff:
---
libstdc++-v3/testsuite/20_util/constant_wrapper/generic.cc | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/libstdc++-v3/testsuite/20_util/constant_wrapper/generic.cc b/libstdc++-v3/testsuite/20_util/constant_wrapper/generic.cc
index 7538efead49d..bd41fc4ca3a1 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 <functional>
#include <utility>
#include <string_view>
-#include <stdexcept>
#include <testsuite_hooks.h>
@@ -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<ThrowFunc{}>(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<ThrowIndex{}>[std::cw<-1>, std::cw<1>];
VERIFY(false);
- } catch (const std::invalid_argument&) {
+ } catch (const NegativeArgument&) {
VERIFY(true);
}
}