From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 956263857010; Tue, 7 Jul 2020 22:30:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 956263857010 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1594161034; bh=5xBUs3ueAXiataPj0M9+hjaOnsrz41fAC0EQOob0hmM=; h=From:To:Subject:Date:From; b=Ami6ps/YLuCMS2DDMuVCISNdBmfIvkjW8lST802Qrn35qeII9pFex3980Kiv3AJ6U 7beTUeVyFE76y4G1lbXPcAR/hrkIg7LLqGvcQ74akSsxI7b56Zq7gTZI/uGdFMvFCv Lr0PKi38becjbTXnNcDYdXkkCrMhNScAYSxWj1ow= From: "hstong at ca dot ibm.com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/96105] New: GCC not consistent on whether no_unique_address array is an empty data member Date: Tue, 07 Jul 2020 22:30:34 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: accepts-invalid, rejects-valid, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: hstong at ca dot ibm.com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Jul 2020 22:30:34 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96105 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 ar= ray 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 (): 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=3Dc++2a -Wall -Wextra -pedantic-errors -xc++ - ### ACTUAL OUTPUT: :19:13: error: conflicting declaration 'char szb [8]' :18:13: note: previous declaration as 'char szb [4]' ### EXPECTED OUTPUT: (clean compile) ### COMPILER VERSION INFO (g++ -v): Using built-in specs. COLLECT_GCC=3D/opt/wandbox/gcc-head/bin/g++ COLLECT_LTO_WRAPPER=3D/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=3D/opt/wandbox/gcc-head --enable-languages=3Dc,c++ --disable-multilib --without-ppl --without-cloog= -ppl --enable-checking=3Drelease --disable-nls --enable-lto LDFLAGS=3D-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)=