public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96052] New: Unlike Clang, alignment specifier is ignored on empty no_unique_address members
@ 2020-07-04 1:49 hstong at ca dot ibm.com
2020-07-10 3:13 ` [Bug c++/96052] " jason at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: hstong at ca dot ibm.com @ 2020-07-04 1:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96052
Bug ID: 96052
Summary: Unlike Clang, alignment specifier is ignored on empty
no_unique_address members
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Keywords: accepts-invalid, rejects-valid, wrong-code
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: hstong at ca dot ibm.com
Target Milestone: ---
Target: x86_64-pc-linux-gnu
The following fully standard (if not portable) C++ source fails to compile with
GCC and does compile with Clang when targeting the same platform. This is
indicative of an ABI incompatibility that is presumably unintended.
Compiler Explorer link: https://godbolt.org/z/RG_QKE
### SOURCE (<stdin>):
struct Q {
struct {
} emp alignas(8) [[no_unique_address]];
char x;
};
struct QQ {
char x;
Q q;
};
struct Z {
char x alignas(8) [[no_unique_address]];
};
struct ZZ {
char x;
Z z;
};
extern char qx[sizeof(QQ)];
extern char qx[16];
extern char qz[sizeof(ZZ)];
extern char qz[16];
### COMPILER INVOCATION:
g++ -fsyntax-only -std=c++20 -Wall -Wextra -pedantic-errors -xc++ -
### ACTUAL OUTPUT:
<stdin>:20:13: error: conflicting declaration 'char qx [16]'
<stdin>:19:13: note: previous declaration as 'char qx [2]'
### EXPECTED OUTPUT:
(clean compile)
### COMPILER VERSION INFO (g++ -v):
Using built-in specs.
COLLECT_GCC=/opt/wandbox/gcc-head/bin/g++
COLLECT_LTO_WRAPPER=/opt/wandbox/gcc-head/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../source/configure --prefix=/opt/wandbox/gcc-head
--enable-languages=c,c++ --disable-multilib --without-ppl --without-cloog-ppl
--enable-checking=release --disable-nls --enable-lto
LDFLAGS=-Wl,-rpath,/opt/wandbox/gcc-head/lib,-rpath,/opt/wandbox/gcc-head/lib64,-rpath,/opt/wandbox/gcc-head/lib32
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20200702 (experimental) (GCC)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/96052] Unlike Clang, alignment specifier is ignored on empty no_unique_address members
2020-07-04 1:49 [Bug c++/96052] New: Unlike Clang, alignment specifier is ignored on empty no_unique_address members hstong at ca dot ibm.com
@ 2020-07-10 3:13 ` jason at gcc dot gnu.org
2020-07-10 12:36 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2020-07-10 3:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96052
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2020-07-10
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/96052] Unlike Clang, alignment specifier is ignored on empty no_unique_address members
2020-07-04 1:49 [Bug c++/96052] New: Unlike Clang, alignment specifier is ignored on empty no_unique_address members hstong at ca dot ibm.com
2020-07-10 3:13 ` [Bug c++/96052] " jason at gcc dot gnu.org
@ 2020-07-10 12:36 ` cvs-commit at gcc dot gnu.org
2020-07-10 12:36 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-07-10 12:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96052
--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:
https://gcc.gnu.org/g:3bb330022ce47a3e8966a9930f392e497c608f59
commit r10-8456-g3bb330022ce47a3e8966a9930f392e497c608f59
Author: Jason Merrill <jason@redhat.com>
Date: Thu Jul 9 15:11:12 2020 -0400
c++: [[no_unique_address]] fixes. [PR96105]
We were wrongly checking is_empty_class on the result of strip_array_types
rather than the actual field type. We weren't considering the alignment of
the data member. We needed to handle unions the same way as
layout_nonempty_base_or_field.
gcc/cp/ChangeLog:
PR c++/96105
PR c++/96052
PR c++/95976
* class.c (check_field_decls): An array of empty classes is not an
empty data member.
(layout_empty_base_or_field): Handle explicit alignment.
Fix union handling.
gcc/testsuite/ChangeLog:
PR c++/96105
PR c++/96052
PR c++/95976
* g++.dg/cpp2a/no_unique_address4.C: New test.
* g++.dg/cpp2a/no_unique_address5.C: New test.
* g++.dg/cpp2a/no_unique_address6.C: New test.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/96052] Unlike Clang, alignment specifier is ignored on empty no_unique_address members
2020-07-04 1:49 [Bug c++/96052] New: Unlike Clang, alignment specifier is ignored on empty no_unique_address members hstong at ca dot ibm.com
2020-07-10 3:13 ` [Bug c++/96052] " jason at gcc dot gnu.org
2020-07-10 12:36 ` cvs-commit at gcc dot gnu.org
@ 2020-07-10 12:36 ` cvs-commit at gcc dot gnu.org
2020-08-04 17:34 ` jason at gcc dot gnu.org
2020-08-04 17:35 ` jason at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-07-10 12:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96052
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:
https://gcc.gnu.org/g:e47dfca5aa473e77fdff95d631dc39de87a41eec
commit r11-2014-ge47dfca5aa473e77fdff95d631dc39de87a41eec
Author: Jason Merrill <jason@redhat.com>
Date: Thu Jul 9 15:11:12 2020 -0400
c++: [[no_unique_address]] fixes. [PR96105]
We were wrongly checking is_empty_class on the result of strip_array_types
rather than the actual field type. We weren't considering the alignment of
the data member. We needed to handle unions the same way as
layout_nonempty_base_or_field.
gcc/cp/ChangeLog:
PR c++/96105
PR c++/96052
PR c++/95976
* class.c (check_field_decls): An array of empty classes is not an
empty data member.
(layout_empty_base_or_field): Handle explicit alignment.
Fix union handling.
gcc/testsuite/ChangeLog:
PR c++/96105
PR c++/96052
PR c++/95976
* g++.dg/cpp2a/no_unique_address4.C: New test.
* g++.dg/cpp2a/no_unique_address5.C: New test.
* g++.dg/cpp2a/no_unique_address6.C: New test.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/96052] Unlike Clang, alignment specifier is ignored on empty no_unique_address members
2020-07-04 1:49 [Bug c++/96052] New: Unlike Clang, alignment specifier is ignored on empty no_unique_address members hstong at ca dot ibm.com
` (2 preceding siblings ...)
2020-07-10 12:36 ` cvs-commit at gcc dot gnu.org
@ 2020-08-04 17:34 ` jason at gcc dot gnu.org
2020-08-04 17:35 ` jason at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2020-08-04 17:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96052
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|11.0 |10.2.1
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 10.2/11.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/96052] Unlike Clang, alignment specifier is ignored on empty no_unique_address members
2020-07-04 1:49 [Bug c++/96052] New: Unlike Clang, alignment specifier is ignored on empty no_unique_address members hstong at ca dot ibm.com
` (3 preceding siblings ...)
2020-08-04 17:34 ` jason at gcc dot gnu.org
@ 2020-08-04 17:35 ` jason at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2020-08-04 17:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96052
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |10.2
Version|10.2.1 |11.0
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-08-04 17:35 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-04 1:49 [Bug c++/96052] New: Unlike Clang, alignment specifier is ignored on empty no_unique_address members hstong at ca dot ibm.com
2020-07-10 3:13 ` [Bug c++/96052] " jason at gcc dot gnu.org
2020-07-10 12:36 ` cvs-commit at gcc dot gnu.org
2020-07-10 12:36 ` cvs-commit at gcc dot gnu.org
2020-08-04 17:34 ` jason at gcc dot gnu.org
2020-08-04 17:35 ` jason 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).