public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/104395] New: alignof is a C++11 feature. src/c++98/bitmap_allocator.cc???
@ 2022-02-05 5:25 unlvsur at live dot com
2022-02-05 5:35 ` [Bug libstdc++/104395] " unlvsur at live dot com
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: unlvsur at live dot com @ 2022-02-05 5:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104395
Bug ID: 104395
Summary: alignof is a C++11 feature.
src/c++98/bitmap_allocator.cc???
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: unlvsur at live dot com
Target Milestone: ---
https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/src/c%2B%2B98/bitmap_allocator.cc
https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/ext/bitmap_allocator.h
clang provides the option -faligned-allocation. It would define that macro even
in C++98 mode. Probably we need to detect whether __cplusplus >= 201103L?
/home/cqwrteur/myhome/gcc_build/native/wasm32-wasi/libstdc++-v3/include/ext/bitmap_allocator.h:1047:18:
error: unexpected type name 'value_type': expected expression
if (alignof(value_type) > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
^
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/104395] alignof is a C++11 feature. src/c++98/bitmap_allocator.cc???
2022-02-05 5:25 [Bug libstdc++/104395] New: alignof is a C++11 feature. src/c++98/bitmap_allocator.cc??? unlvsur at live dot com
@ 2022-02-05 5:35 ` unlvsur at live dot com
2022-02-05 5:40 ` unlvsur at live dot com
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: unlvsur at live dot com @ 2022-02-05 5:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104395
--- Comment #1 from cqwrteur <unlvsur at live dot com> ---
/home/cqwrteur/myhome/gcc_build/native/wasm32-wasi/libstdc++-v3/include/ext/pool_allocator.h:274:16:
error: '_Tp' does not refer to a value
if (alignof(_Tp) > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
^
Sounds like a weird issue in clang 15.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/104395] alignof is a C++11 feature. src/c++98/bitmap_allocator.cc???
2022-02-05 5:25 [Bug libstdc++/104395] New: alignof is a C++11 feature. src/c++98/bitmap_allocator.cc??? unlvsur at live dot com
2022-02-05 5:35 ` [Bug libstdc++/104395] " unlvsur at live dot com
@ 2022-02-05 5:40 ` unlvsur at live dot com
2022-02-05 5:43 ` unlvsur at live dot com
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: unlvsur at live dot com @ 2022-02-05 5:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104395
cqwrteur <unlvsur at live dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #2 from cqwrteur <unlvsur at live dot com> ---
It seems to be other issues rather than this one. close.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/104395] alignof is a C++11 feature. src/c++98/bitmap_allocator.cc???
2022-02-05 5:25 [Bug libstdc++/104395] New: alignof is a C++11 feature. src/c++98/bitmap_allocator.cc??? unlvsur at live dot com
2022-02-05 5:35 ` [Bug libstdc++/104395] " unlvsur at live dot com
2022-02-05 5:40 ` unlvsur at live dot com
@ 2022-02-05 5:43 ` unlvsur at live dot com
2022-02-05 5:46 ` unlvsur at live dot com
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: unlvsur at live dot com @ 2022-02-05 5:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104395
cqwrteur <unlvsur at live dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |---
--- Comment #3 from cqwrteur <unlvsur at live dot com> ---
#include<ext/bitmap_allocator.h>
#include<ext/new_allocator.h>
int main()
{
__gnu_cxx::new_allocator<int> n;
n.allocate(3);
}
clang++ -o a a.cc -faligned-allocation -fsized-deallocation -s -flto
-fuse-ld=lld -std=c++98
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/12.0.1/../../../../include/c++/12.0.1/bits/new_allocator.h:55:21:
note: de
clared here
template<typename _Tp>
^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/12.0.1/../../../../include/c++/12.0.1/bits/new_allocator.h:132:55:
error: '_Tp' does not refer to a value
std::align_val_t __al = std::align_val_t(alignof(_Tp));
Sounds like a C++98 issue.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/104395] alignof is a C++11 feature. src/c++98/bitmap_allocator.cc???
2022-02-05 5:25 [Bug libstdc++/104395] New: alignof is a C++11 feature. src/c++98/bitmap_allocator.cc??? unlvsur at live dot com
` (2 preceding siblings ...)
2022-02-05 5:43 ` unlvsur at live dot com
@ 2022-02-05 5:46 ` unlvsur at live dot com
2022-02-05 7:46 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: unlvsur at live dot com @ 2022-02-05 5:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104395
--- Comment #4 from cqwrteur <unlvsur at live dot com> ---
also in all xxx_allocator.h including mt_allocator.h pool_allocator.h
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/104395] alignof is a C++11 feature. src/c++98/bitmap_allocator.cc???
2022-02-05 5:25 [Bug libstdc++/104395] New: alignof is a C++11 feature. src/c++98/bitmap_allocator.cc??? unlvsur at live dot com
` (3 preceding siblings ...)
2022-02-05 5:46 ` unlvsur at live dot com
@ 2022-02-05 7:46 ` pinskia at gcc dot gnu.org
2022-02-05 8:54 ` [Bug libstdc++/104395] ext/bitmap_allocator.h is not C++98 friendly when using with -faligned-new unlvsur at live dot com
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-02-05 7:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104395
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
GCC's option is -faligned-new -fsized-deallocation -std=c++98
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/104395] ext/bitmap_allocator.h is not C++98 friendly when using with -faligned-new
2022-02-05 5:25 [Bug libstdc++/104395] New: alignof is a C++11 feature. src/c++98/bitmap_allocator.cc??? unlvsur at live dot com
` (4 preceding siblings ...)
2022-02-05 7:46 ` pinskia at gcc dot gnu.org
@ 2022-02-05 8:54 ` unlvsur at live dot com
2024-06-26 10:56 ` redi at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: unlvsur at live dot com @ 2022-02-05 8:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104395
--- Comment #6 from cqwrteur <unlvsur at live dot com> ---
(In reply to Andrew Pinski from comment #5)
> GCC's option is -faligned-new -fsized-deallocation -std=c++98
yeah gcc does not work either.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/104395] ext/bitmap_allocator.h is not C++98 friendly when using with -faligned-new
2022-02-05 5:25 [Bug libstdc++/104395] New: alignof is a C++11 feature. src/c++98/bitmap_allocator.cc??? unlvsur at live dot com
` (5 preceding siblings ...)
2022-02-05 8:54 ` [Bug libstdc++/104395] ext/bitmap_allocator.h is not C++98 friendly when using with -faligned-new unlvsur at live dot com
@ 2024-06-26 10:56 ` redi at gcc dot gnu.org
2024-06-26 10:58 ` redi at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2024-06-26 10:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104395
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
It doesn't seem very helpful for GCC and Clang to accept enum class align_val_t
in C++98 mode, but not accept alignof in system headers.
We could change all these uses to __alignof instead of alignof, which would
work with C++98. But the semantics of alignof and __alignof are slightly
different. Maybe the difference only matters for long long, and not for any
overaligned types, but I'm not sure.
I think the simple answer is that you should not use -faligned-new in C++98
mode.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/104395] ext/bitmap_allocator.h is not C++98 friendly when using with -faligned-new
2022-02-05 5:25 [Bug libstdc++/104395] New: alignof is a C++11 feature. src/c++98/bitmap_allocator.cc??? unlvsur at live dot com
` (6 preceding siblings ...)
2024-06-26 10:56 ` redi at gcc dot gnu.org
@ 2024-06-26 10:58 ` redi at gcc dot gnu.org
2024-06-27 11:01 ` redi at gcc dot gnu.org
2024-06-28 19:23 ` cvs-commit at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2024-06-26 10:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104395
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu.org
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #7)
> It doesn't seem very helpful for GCC and Clang to accept enum class
> align_val_t in C++98 mode, but not accept alignof in system headers.
It would only need to be accepted when -faligned-new / -faligned-allocation is
active, which is already requesting a non-standard extension to C++98.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/104395] ext/bitmap_allocator.h is not C++98 friendly when using with -faligned-new
2022-02-05 5:25 [Bug libstdc++/104395] New: alignof is a C++11 feature. src/c++98/bitmap_allocator.cc??? unlvsur at live dot com
` (7 preceding siblings ...)
2024-06-26 10:58 ` redi at gcc dot gnu.org
@ 2024-06-27 11:01 ` redi at gcc dot gnu.org
2024-06-28 19:23 ` cvs-commit at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2024-06-27 11:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104395
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
URL| |https://gcc.gnu.org/piperma
| |il/gcc-patches/2024-June/65
| |5842.html
Last reconfirmed| |2024-06-27
Keywords| |patch
Ever confirmed|0 |1
Status|UNCONFIRMED |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org
--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Patch posted: https://gcc.gnu.org/pipermail/gcc-patches/2024-June/655842.html
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/104395] ext/bitmap_allocator.h is not C++98 friendly when using with -faligned-new
2022-02-05 5:25 [Bug libstdc++/104395] New: alignof is a C++11 feature. src/c++98/bitmap_allocator.cc??? unlvsur at live dot com
` (8 preceding siblings ...)
2024-06-27 11:01 ` redi at gcc dot gnu.org
@ 2024-06-28 19:23 ` cvs-commit at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-06-28 19:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104395
--- Comment #10 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:
https://gcc.gnu.org/g:03d3aeb0e0fa7dec9bd702cabf57ef73cdc32704
commit r15-1714-g03d3aeb0e0fa7dec9bd702cabf57ef73cdc32704
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Jun 26 14:09:07 2024 +0100
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.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2024-06-28 19:23 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-05 5:25 [Bug libstdc++/104395] New: alignof is a C++11 feature. src/c++98/bitmap_allocator.cc??? unlvsur at live dot com
2022-02-05 5:35 ` [Bug libstdc++/104395] " unlvsur at live dot com
2022-02-05 5:40 ` unlvsur at live dot com
2022-02-05 5:43 ` unlvsur at live dot com
2022-02-05 5:46 ` unlvsur at live dot com
2022-02-05 7:46 ` pinskia at gcc dot gnu.org
2022-02-05 8:54 ` [Bug libstdc++/104395] ext/bitmap_allocator.h is not C++98 friendly when using with -faligned-new unlvsur at live dot com
2024-06-26 10:56 ` redi at gcc dot gnu.org
2024-06-26 10:58 ` redi at gcc dot gnu.org
2024-06-27 11:01 ` redi at gcc dot gnu.org
2024-06-28 19:23 ` cvs-commit at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).