diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2020-12-16 15:54:50 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2020-12-16 19:25:09 +0000 |
commit | 767537a8b027bcb5807bb45b0268c5da98c2c7a0 (patch) | |
tree | 6b0ef58634ac26c6e2575c1f60427f56248ffea9 /libstdc++-v3 | |
parent | e128aaa6e5d792425afffdeac421f5076c15b9f0 (diff) | |
download | gcc-767537a8b027bcb5807bb45b0268c5da98c2c7a0.zip gcc-767537a8b027bcb5807bb45b0268c5da98c2c7a0.tar.gz gcc-767537a8b027bcb5807bb45b0268c5da98c2c7a0.tar.bz2 |
libstdc++: Warn if __STRICT_ANSI has been undefined
Recent changes to use __int128 as an integer-like type in <ranges> and
to optimize std::uniform_int_distribution mean that the library relies
on __int128 more heavily than in the past.
The library expects that if __int128 is supported then either
__GLIBCXX_TYPE_INT_N_0 is defined (and we treat is like the standard
integer types), or __STRICT_ANSI__ is defined (and we need to add
special handling for __int128 as a non-standard integer type).
If users compile with -std=c++NN -U__STRICT_ANSI__ then it puts the
library into a broken and inconsistent state, where the compiler doesn't
define the __GLIBCXX_TYPE_INT_N_0 macro, but the library thinks it
doesn't need special handling for __int128. What the user should do is
compile with -std=gnu++NN instead.
This adds a warning if it appears that __int128 is supported but neither
__GLIBCXX_TYPE_INT_N_0 nor __STRICT_ANSI__ is defined.
libstdc++-v3/ChangeLog:
* include/bits/c++config: Warn if __STRICT_ANSI__ state is
inconsistent with __GLIBCXX_TYPE_INT_N_0.
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/include/bits/c++config | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index 155d0f4..cd7678e 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -524,6 +524,15 @@ namespace std #define _GLIBCXX_USE_ALLOCATOR_NEW +#ifdef __SIZEOF_INT128__ +#if ! defined __GLIBCXX_TYPE_INT_N_0 && ! defined __STRICT_ANSI__ +// If __int128 is supported, we expect __GLIBCXX_TYPE_INT_N_0 to be defined +// unless the compiler is in strict mode. If it's not defined and the strict +// macro is not defined, something is wrong. +#warning "__STRICT_ANSI__ seems to have been undefined; this is not supported" +#endif +#endif + #else // !__cplusplus # define _GLIBCXX_BEGIN_EXTERN_C # define _GLIBCXX_END_EXTERN_C |