Tested x86_64-pc-linux-gnu, OK for trunk?

-- 8< --

<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>.

The exception/safety.h hunk isn't necessitated by this change, it's just to
properly include dependencies, but seemed thematic.  I'm happy to separate it
if that's preferred.

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                  | 7 +------
 libstdc++-v3/testsuite/util/exception/safety.h             | 1 +
 .../17_intro/headers/c++1998/stdc++_assert_neg.cc          | 1 -
 3 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/libstdc++-v3/include/precompiled/stdc++.h 
b/libstdc++-v3/include/precompiled/stdc++.h
index 636632a4439..54baed43a5e 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 8226c176201..c62394cf082 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 eb380c411c3..f6200274a13 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,5 +1,4 @@
 // { 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.

base-commit: 2be505ace7e5e29a29ab53025762cf1a100a6d76
-- 
2.51.0

Reply via email to