https://gcc.gnu.org/g:046776dac7cc74bdbab36f450af80644a045858a

commit r14-12513-g046776dac7cc74bdbab36f450af80644a045858a
Author: Andrew Pinski <[email protected]>
Date:   Mon Nov 25 14:03:27 2024 -0800

    build: Move sstream and memory include above safe-ctype.h [PR124830]
    
    This picks r15-5661-gf6e00226a4ca6 to older branches, also moving
    the <memory> include to fix build issues with a C++20 host compiler.
    
    sstream in some versions of libstdc++ include locale which might not have 
been
    included yet. safe-ctype.h defines the toupper, tolower, etc. as macros so 
the
    c++ header files needed to be included before hand as comment in system.h 
says:
    /* Include C++ standard headers before "safe-ctype.h" to avoid GCC
       poisoning the ctype macros through safe-ctype.h */
    
    I don't understand how it was working before when memory was included after
    safe-ctype.h rather than before. But this makes sstream consistent with the
    other C++ headers.
    
    gcc/ChangeLog:
    
            PR target/117771
            PR c/124830
            * system.h: Move the include of sstream and memory above 
safe-ctype.h.
    
    Signed-off-by: Andrew Pinski <[email protected]>

Diff:
---
 gcc/system.h | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/gcc/system.h b/gcc/system.h
index b18482c7190f..da331f105bad 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -222,6 +222,15 @@ extern int fprintf_unlocked (FILE *, const char *, ...);
 #ifdef INCLUDE_FUNCTIONAL
 # include <functional>
 #endif
+#ifdef INCLUDE_SSTREAM
+# include <sstream>
+#endif
+/* Some of the headers included by <memory> can use "abort" within a
+   namespace, e.g. "_VSTD::abort();", which fails after we use the
+   preprocessor to redefine "abort" as "fancy_abort" below.  */
+#ifdef INCLUDE_MEMORY
+# include <memory>
+#endif
 # include <cstring>
 # include <initializer_list>
 # include <new>
@@ -758,22 +767,10 @@ private:
 #define LIKELY(x) (__builtin_expect ((x), 1))
 #define UNLIKELY(x) (__builtin_expect ((x), 0))
 
-/* Some of the headers included by <memory> can use "abort" within a
-   namespace, e.g. "_VSTD::abort();", which fails after we use the
-   preprocessor to redefine "abort" as "fancy_abort" below.  */
-
-#ifdef INCLUDE_MEMORY
-# include <memory>
-#endif
-
 #ifdef INCLUDE_MUTEX
 # include <mutex>
 #endif
 
-#ifdef INCLUDE_SSTREAM
-# include <sstream>
-#endif
-
 #ifdef INCLUDE_MALLOC_H
 #if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2)
 #include <malloc.h>

Reply via email to