]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: remove cassert from stdc++.h
authorJason Merrill <jason@redhat.com>
Mon, 3 Nov 2025 15:55:06 +0000 (18:55 +0300)
committerJason Merrill <jason@redhat.com>
Mon, 3 Nov 2025 15:55:06 +0000 (18:55 +0300)
<cassert> isn't suitable for a header unit, because by design it depends on
the user NDEBUG macro.  So let's not include it in <bits/stdc++.h>.

libstdc++-v3/ChangeLog:

* include/precompiled/stdc++.h: Remove <cassert>.
* testsuite/util/exception/safety.h: Add <cassert>.
* testsuite/17_intro/headers/c++1998/stdc++_assert_neg.cc:
Don't define _GLIBCXX_NO_ASSERT.

libstdc++-v3/include/precompiled/stdc++.h
libstdc++-v3/testsuite/17_intro/headers/c++1998/stdc++_assert_neg.cc
libstdc++-v3/testsuite/util/exception/safety.h

index 636632a443921381f5f143fd400e178668788cce..54baed43a5e2d4775b11429837c7c2e0cf05fc13 100644 (file)
@@ -29,9 +29,7 @@
 // 17.4.1.2 Headers
 
 // C
-#ifndef _GLIBCXX_NO_ASSERT
-#include <cassert>
-#endif
+// Don't include cassert, it's not suitable for PCH or header unit.
 #include <cctype>
 #include <cfloat>
 #include <climits>
 
 #if _GLIBCXX_HOSTED
 // C
-#ifndef _GLIBCXX_NO_ASSERT
-#include <cassert>
-#endif
 #include <cctype>
 #include <cerrno>
 #include <cfloat>
index eb380c411c339e7520e444381e0eaf32a74b2285..7ce90a29d72497dbedb33059aed9405d54a5fefc 100644 (file)
@@ -1,8 +1,5 @@
 // { dg-do compile }
-// { dg-options "-D_GLIBCXX_NO_ASSERT" }
 // { dg-require-effective-target hosted }
-// NB: This is done to force any generated and possibly included PCH
-// to be invalid, and also to remove cassert from the include set.
 
 // 2005-05-24 bkoz
 
index 8226c1762016aabf83a5ea38d059bc3228f5c9a1..c62394cf0825237976a2ae55ff0b7f3d6de16291 100644 (file)
@@ -24,6 +24,7 @@
 #include <ext/throw_allocator.h>
 #include <cstdlib> // getenv, atoi
 #include <cstdio>  // printf, fflush
+#include <cassert> // assert
 
 // Container requirement testing.
 namespace __gnu_test