public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96105] New: GCC not consistent on whether no_unique_address array is an empty data member
@ 2020-07-07 22:30 hstong at ca dot ibm.com
2020-07-07 22:44 ` [Bug c++/96105] " dje at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: hstong at ca dot ibm.com @ 2020-07-07 22:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96105
Bug ID: 96105
Summary: GCC not consistent on whether no_unique_address array
is an empty data member
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: ---
GCC treats an array marked `no_unique_address` and whose base element type is
an empty class as not an empty data member in `C` but does treat such an array
as an empty data member in `A` for the purposes of `B`. It appears that GCC's
handling of `B` is erroneous.
Compiler Explorer link: https://godbolt.org/z/XX5W3v
### SOURCE (<stdin>):
struct Empty {};
struct A {
Empty emp [[no_unique_address]][3];
};
struct B : A {
float f;
};
struct C {
Empty emp [[no_unique_address]][3];
float f;
};
extern char szc[sizeof(C)];
extern char szc[sizeof(float) * 2]; // GCC likes this
extern char szb[sizeof(B)];
extern char szb[sizeof(float) * 2]; // GCC does not like this
### COMPILER INVOCATION:
g++ -fsyntax-only -std=c++2a -Wall -Wextra -pedantic-errors -xc++ -
### ACTUAL OUTPUT:
<stdin>:19:13: error: conflicting declaration 'char szb [8]'
<stdin>:18:13: note: previous declaration as 'char szb [4]'
### 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 20200706 (experimental) (GCC)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/96105] GCC not consistent on whether no_unique_address array is an empty data member
2020-07-07 22:30 [Bug c++/96105] New: GCC not consistent on whether no_unique_address array is an empty data member hstong at ca dot ibm.com
@ 2020-07-07 22:44 ` dje at gcc dot gnu.org
2020-07-09 15:17 ` jason at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: dje at gcc dot gnu.org @ 2020-07-07 22:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96105
David Edelsohn <dje at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
CC| |dje at gcc dot gnu.org,
| |jakub at gcc dot gnu.org,
| |redi at gcc dot gnu.org
Last reconfirmed| |2020-07-07
--- Comment #1 from David Edelsohn <dje at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/96105] GCC not consistent on whether no_unique_address array is an empty data member
2020-07-07 22:30 [Bug c++/96105] New: GCC not consistent on whether no_unique_address array is an empty data member hstong at ca dot ibm.com
2020-07-07 22:44 ` [Bug c++/96105] " dje at gcc dot gnu.org
@ 2020-07-09 15:17 ` jason at gcc dot gnu.org
2020-07-09 15:19 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2020-07-09 15:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96105
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/96105] GCC not consistent on whether no_unique_address array is an empty data member
2020-07-07 22:30 [Bug c++/96105] New: GCC not consistent on whether no_unique_address array is an empty data member hstong at ca dot ibm.com
2020-07-07 22:44 ` [Bug c++/96105] " dje at gcc dot gnu.org
2020-07-09 15:17 ` jason at gcc dot gnu.org
@ 2020-07-09 15:19 ` jakub at gcc dot gnu.org
2020-07-10 12:36 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-07-09 15:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96105
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Other no_unique_address ABI issues: PR96052, PR95976
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/96105] GCC not consistent on whether no_unique_address array is an empty data member
2020-07-07 22:30 [Bug c++/96105] New: GCC not consistent on whether no_unique_address array is an empty data member hstong at ca dot ibm.com
` (2 preceding siblings ...)
2020-07-09 15:19 ` jakub 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:36 ` jason at gcc dot gnu.org
5 siblings, 0 replies; 7+ 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=96105
--- Comment #3 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] 7+ messages in thread
* [Bug c++/96105] GCC not consistent on whether no_unique_address array is an empty data member
2020-07-07 22:30 [Bug c++/96105] New: GCC not consistent on whether no_unique_address array is an empty data member hstong at ca dot ibm.com
` (3 preceding siblings ...)
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:36 ` jason at gcc dot gnu.org
5 siblings, 0 replies; 7+ 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=96105
--- Comment #4 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] 7+ messages in thread
* [Bug c++/96105] GCC not consistent on whether no_unique_address array is an empty data member
2020-07-07 22:30 [Bug c++/96105] New: GCC not consistent on whether no_unique_address array is an empty data member hstong at ca dot ibm.com
` (4 preceding siblings ...)
2020-07-10 12:36 ` cvs-commit at gcc dot gnu.org
@ 2020-08-04 17:36 ` jason at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2020-08-04 17:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96105
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |10.2
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 10.2/11.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-08-04 17:36 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-07 22:30 [Bug c++/96105] New: GCC not consistent on whether no_unique_address array is an empty data member hstong at ca dot ibm.com
2020-07-07 22:44 ` [Bug c++/96105] " dje at gcc dot gnu.org
2020-07-09 15:17 ` jason at gcc dot gnu.org
2020-07-09 15:19 ` jakub 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:36 ` 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).