From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B5FD83858D1E; Tue, 14 Feb 2023 16:33:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B5FD83858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676392400; bh=V+Oe5bhLdiYjDfHNkZbdqAey3mRvCWsmHg54n5hZ4xs=; h=From:To:Subject:Date:From; b=FVjtMQYzCNh/w+KvwmFpv/DizyjOQJfeplzZ/5WXD4CpgXh49UCAZJxLsWaKkzCzu 6ydTTkaZQSz2buK20pNit4kS91TGvQbd4duOUVxWyBMqRaQoNiJxGcRFQhK8no+IH4 vS1s3lTQ4G+4XcChBDCJDITFTNWdJ68yMZW1uD6U= From: "m.cencora at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/108788] New: Lookup of injected class name should be type-dependent Date: Tue, 14 Feb 2023 16:33:20 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: m.cencora at gmail dot 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 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108788 Bug ID: 108788 Summary: Lookup of injected class name should be type-dependent Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: m.cencora at gmail dot com Target Milestone: --- Following code fails to compile on any gcc version. Works on all clang versions. It looks like inside template function get_templ_base the lookup of v.templ_base::a is done eagerly, and finds templ_base at the global scope, = and hence errors out because the template parameters are missing. But at this point qualified name "templ_base::a" should be type-dependent, = so lookup should be delayed until template instantiation, where 'templ_base' i= s an injected class name, so template paremeters shouldn't be required. g++ -std=3Dc++11 struct base { int a =3D 1; }; template struct templ_base { int a =3D 2; }; namespace bar { struct base2 { int a =3D 3; }; template struct templ_base2 { int a =3D 4; }; } struct foo : base, bar::templ_base2, templ_base, bar::base2 { int base =3D 5; int templ_base =3D 6; int base2 =3D 7; int templ_base2 =3D 8; int a =3D 9; }; static_assert(foo{}.base::a =3D=3D 1, ""); static_assert(foo{}.templ_base::a =3D=3D 2, ""); static_assert(foo{}.base2::a =3D=3D 3, ""); static_assert(foo{}.templ_base2::a =3D=3D 4, ""); template int get_base(T&& v) { return v.base::a; } template int get_templ_base(T&& v) { return v.templ_base::a; // fails in all gcc versions } template int get_base2(T&& v) { return v.base2::a; // fails for gcc <=3D 11 } template int get_templ_base2(T&& v) { return v.templ_base2::a; // fails for gcc <=3D 11 } int a =3D get_base(foo{}); int b =3D get_templ_base(foo{}); int c =3D get_base2(foo{}); int d =3D get_templ_base2(foo{});=