https://gcc.gnu.org/g:eaf6b40f761049ba4f74fd8bf1bc011e3c59c53b
commit r16-5006-geaf6b40f761049ba4f74fd8bf1bc011e3c59c53b Author: Jason Merrill <[email protected]> Date: Mon Nov 3 18:55:06 2025 +0300 libstdc++: remove cassert from stdc++.h <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. Diff: --- libstdc++-v3/include/precompiled/stdc++.h | 7 +------ libstdc++-v3/testsuite/util/exception/safety.h | 1 + .../testsuite/17_intro/headers/c++1998/stdc++_assert_neg.cc | 3 --- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/libstdc++-v3/include/precompiled/stdc++.h b/libstdc++-v3/include/precompiled/stdc++.h index 636632a44392..54baed43a5e2 100644 --- a/libstdc++-v3/include/precompiled/stdc++.h +++ b/libstdc++-v3/include/precompiled/stdc++.h @@ -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> @@ -104,9 +102,6 @@ #if _GLIBCXX_HOSTED // C -#ifndef _GLIBCXX_NO_ASSERT -#include <cassert> -#endif #include <cctype> #include <cerrno> #include <cfloat> diff --git a/libstdc++-v3/testsuite/util/exception/safety.h b/libstdc++-v3/testsuite/util/exception/safety.h index 8226c1762016..c62394cf0825 100644 --- a/libstdc++-v3/testsuite/util/exception/safety.h +++ b/libstdc++-v3/testsuite/util/exception/safety.h @@ -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 diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++1998/stdc++_assert_neg.cc b/libstdc++-v3/testsuite/17_intro/headers/c++1998/stdc++_assert_neg.cc index eb380c411c33..7ce90a29d724 100644 --- a/libstdc++-v3/testsuite/17_intro/headers/c++1998/stdc++_assert_neg.cc +++ b/libstdc++-v3/testsuite/17_intro/headers/c++1998/stdc++_assert_neg.cc @@ -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
