gcc/libstdc++-v3/include/ext
Jonathan Wakely b48785e9ab libstdc++: Do not use C++11 alignof in C++98 mode [PR104395]
When -faligned-new (or Clang's -faligned-allocation) is used our
allocators try to support extended alignments, gated on the
__cpp_aligned_new macro. However, because they use alignof(_Tp) which is
not a keyword in C++98 mode, using -std=c++98 -faligned-new results in
errors from <memory> and other headers.

We could change them to use __alignof__ instead of alignof, but that
would potentially alter the result of the conditions, because e.g.
alignof(long long) != __alignof__(long long) on some targets. That's
probably not an issue for any types with extended alignment, so maybe it
would be a safe change.

For now, it seems acceptable to just disable the extended alignment
support in C++98 mode, so that -faligned-new enables std::align_val_t
and the corresponding operator new overloads, but doesn't affect
std::allocator, __gnu_cxx::__bitmap_allocator etc.

libstdc++-v3/ChangeLog:

	PR libstdc++/104395
	* include/bits/new_allocator.h: Disable extended alignment
	support in C++98 mode.
	* include/ext/bitmap_allocator.h: Likewise.
	* include/ext/malloc_allocator.h: Likewise.
	* include/ext/mt_allocator.h: Likewise.
	* include/ext/pool_allocator.h: Likewise.
	* testsuite/ext/104395.cc: New test.

(cherry picked from commit 03d3aeb0e0)
2025-04-16 20:13:33 +01:00
..
pb_ds Update copyright years. 2023-01-16 11:52:17 +01:00
algorithm Update copyright years. 2023-01-16 11:52:17 +01:00
aligned_buffer.h libstdc++: Suppress warnings about use of deprecated std::aligned_storage 2023-02-24 14:23:35 +00:00
alloc_traits.h Update copyright years. 2023-01-16 11:52:17 +01:00
atomicity.h Update copyright years. 2023-01-16 11:52:17 +01:00
bitmap_allocator.h libstdc++: Do not use C++11 alignof in C++98 mode [PR104395] 2025-04-16 20:13:33 +01:00
cast.h Update copyright years. 2023-01-16 11:52:17 +01:00
cmath Update copyright years. 2023-01-16 11:52:17 +01:00
codecvt_specializations.h Update copyright years. 2023-01-16 11:52:17 +01:00
concurrence.h Update copyright years. 2023-01-16 11:52:17 +01:00
debug_allocator.h Update copyright years. 2023-01-16 11:52:17 +01:00
enc_filebuf.h Update copyright years. 2023-01-16 11:52:17 +01:00
extptr_allocator.h Update copyright years. 2023-01-16 11:52:17 +01:00
functional Update copyright years. 2023-01-16 11:52:17 +01:00
iterator Update copyright years. 2023-01-16 11:52:17 +01:00
malloc_allocator.h libstdc++: Do not use C++11 alignof in C++98 mode [PR104395] 2025-04-16 20:13:33 +01:00
memory Update copyright years. 2023-01-16 11:52:17 +01:00
mt_allocator.h libstdc++: Do not use C++11 alignof in C++98 mode [PR104395] 2025-04-16 20:13:33 +01:00
new_allocator.h Update copyright years. 2023-01-16 11:52:17 +01:00
numeric Update copyright years. 2023-01-16 11:52:17 +01:00
numeric_traits.h Update copyright years. 2023-01-16 11:52:17 +01:00
pod_char_traits.h Update copyright years. 2023-01-16 11:52:17 +01:00
pointer.h Update copyright years. 2023-01-16 11:52:17 +01:00
pool_allocator.h libstdc++: Do not use C++11 alignof in C++98 mode [PR104395] 2025-04-16 20:13:33 +01:00
random Update copyright years. 2023-01-16 11:52:17 +01:00
random.tcc Update copyright years. 2023-01-16 11:52:17 +01:00
rb_tree Update copyright years. 2023-01-16 11:52:17 +01:00
rc_string_base.h Update copyright years. 2023-01-16 11:52:17 +01:00
rope Update copyright years. 2023-01-16 11:52:17 +01:00
ropeimpl.h Update copyright years. 2023-01-16 11:52:17 +01:00
slist Update copyright years. 2023-01-16 11:52:17 +01:00
sso_string_base.h Update copyright years. 2023-01-16 11:52:17 +01:00
stdio_filebuf.h Update copyright years. 2023-01-16 11:52:17 +01:00
stdio_sync_filebuf.h Update copyright years. 2023-01-16 11:52:17 +01:00
string_conversions.h Update copyright years. 2023-01-16 11:52:17 +01:00
throw_allocator.h libstdc++: Fix non-reserved names in <ext/throw_allocator.h> 2023-02-16 11:41:51 +00:00
type_traits.h Update copyright years. 2023-01-16 11:52:17 +01:00
typelist.h Update copyright years. 2023-01-16 11:52:17 +01:00
vstring.h Update copyright years. 2023-01-16 11:52:17 +01:00
vstring.tcc Update copyright years. 2023-01-16 11:52:17 +01:00
vstring_fwd.h Update copyright years. 2023-01-16 11:52:17 +01:00
vstring_util.h Update copyright years. 2023-01-16 11:52:17 +01:00