[Bug c++/96052] New: Unlike Clang, alignment specifier is ignored on empty no_unique_address members
hstong at ca dot ibm.com
gcc-bugzilla@gcc.gnu.org
Sat Jul 4 01:49:44 GMT 2020
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)
More information about the Gcc-bugs
mailing list