diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2024-06-26 14:09:07 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2024-06-28 20:19:02 +0100 |
commit | 03d3aeb0e0fa7dec9bd702cabf57ef73cdc32704 (patch) | |
tree | 095f85467a577f84d9936e43bfa1d1bb7cf67eeb /libstdc++-v3/testsuite | |
parent | ac8c61b62e71ffdcaebfd4cfc03f58fe542855dd (diff) | |
download | gcc-03d3aeb0e0fa7dec9bd702cabf57ef73cdc32704.zip gcc-03d3aeb0e0fa7dec9bd702cabf57ef73cdc32704.tar.gz gcc-03d3aeb0e0fa7dec9bd702cabf57ef73cdc32704.tar.bz2 |
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/bits/stl_tempbuf.h: Likewise.
* 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.
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r-- | libstdc++-v3/testsuite/ext/104395.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/ext/104395.cc b/libstdc++-v3/testsuite/ext/104395.cc new file mode 100644 index 0000000..252c40c --- /dev/null +++ b/libstdc++-v3/testsuite/ext/104395.cc @@ -0,0 +1,8 @@ +// { dg-options "-std=gnu++98 -faligned-new" } +// { dg-do compile } +#include <ext/memory> +#include <ext/bitmap_allocator.h> +#include <ext/mt_allocator.h> +#include <ext/malloc_allocator.h> +#include <ext/new_allocator.h> +#include <ext/pool_allocator.h> |