From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 83BF43861813; Thu, 30 Nov 2023 21:42:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 83BF43861813 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701380559; bh=zE0SRj2Dq59rq1gpYFWz7QbDFyeUBRMbxkguZfQCsTo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=o7e5SIVAg2YHm7w2J8OaVZzbItIKK7laxTHUyJW9ViVM19Lf4A/M1UtKJSaOhGMIF 5o0XGGA84uVO0xxHY89qL82BvDhVH2oUI09OssJeVovewoTLa8mtLNQTmscKeY+Oj7 iKek296F0VneMUyZwMduBBelNvKC+ZmcArO2ExjM= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/112744] Nested name specifier wrongly produces ambiguity in accessing static field Date: Thu, 30 Nov 2023 21:42:39 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.2.1 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112744 --- Comment #2 from GCC Commits --- The trunk branch has been updated by Marek Polacek : https://gcc.gnu.org/g:725c68c54c265fe7f6fc7babff7139f3161bdfa6 commit r14-6024-g725c68c54c265fe7f6fc7babff7139f3161bdfa6 Author: Marek Polacek Date: Tue Nov 28 14:44:24 2023 -0500 c++: wrong ambiguity in accessing static field [PR112744] Given struct A { constexpr static int a =3D 0; }; struct B : A {}; struct C : A {}; struct D : B, C {}; we give the "'A' is an ambiguous base of 'D'" error for D{}.A::a; which seems wrong: 'a' is a static data member so there is only one copy so it can be unambiguously referred to even if there are multiple A objects. clang++/MSVC/icx agree. This patch uses ba_any: [class.access.base] requires conversion to a un= ique base subobject for non-static data members, but it does not require that the base be unique or accessible for static data members. PR c++/112744 gcc/cp/ChangeLog: * typeck.cc (finish_class_member_access_expr): When accessing a static data member, use ba_any for lookup_base. gcc/testsuite/ChangeLog: * g++.dg/lookup/scoped11.C: New test. * g++.dg/lookup/scoped12.C: New test. * g++.dg/lookup/scoped13.C: New test. * g++.dg/lookup/scoped14.C: New test. * g++.dg/lookup/scoped15.C: New test.=