]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix constant_wrapper compile-time test for COW strings.
authorTomasz Kamiński <tkaminsk@redhat.com>
Tue, 14 Apr 2026 12:31:24 +0000 (14:31 +0200)
committerTomasz Kamiński <tkaminsk@redhat.com>
Tue, 14 Apr 2026 12:33:42 +0000 (14:33 +0200)
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.

libstdc++-v3/testsuite/20_util/constant_wrapper/generic.cc

index 7538efead49d40367acac01a9419ef5ae3f491d9..bd41fc4ca3a1a083a069e04523f49ac265202512 100644 (file)
@@ -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);
   }
 }