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.
This commit is contained in:
Jason Merrill
2025-11-03 18:55:06 +03:00
parent 725ce34b6c
commit eaf6b40f76
3 changed files with 2 additions and 9 deletions

View 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>
@@ -104,9 +102,6 @@
#if _GLIBCXX_HOSTED
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>

View 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

View 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