public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "m.cencora at gmail dot com" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-108788-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108788 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' is an injected class name, so template paremeters shouldn't be required. g++ -std=c++11 struct base { int a = 1; }; template <typename T> struct templ_base { int a = 2; }; namespace bar { struct base2 { int a = 3; }; template <typename T> struct templ_base2 { int a = 4; }; } struct foo : base, bar::templ_base2<char>, templ_base<int>, bar::base2 { int base = 5; int templ_base = 6; int base2 = 7; int templ_base2 = 8; int a = 9; }; static_assert(foo{}.base::a == 1, ""); static_assert(foo{}.templ_base::a == 2, ""); static_assert(foo{}.base2::a == 3, ""); static_assert(foo{}.templ_base2::a == 4, ""); template <typename T> int get_base(T&& v) { return v.base::a; } template <typename T> int get_templ_base(T&& v) { return v.templ_base::a; // fails in all gcc versions } template <typename T> int get_base2(T&& v) { return v.base2::a; // fails for gcc <= 11 } template <typename T> int get_templ_base2(T&& v) { return v.templ_base2::a; // fails for gcc <= 11 } int a = get_base(foo{}); int b = get_templ_base(foo{}); int c = get_base2(foo{}); int d = get_templ_base2(foo{});
next reply other threads:[~2023-02-14 16:33 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-02-14 16:33 m.cencora at gmail dot com [this message] 2023-02-14 20:12 ` [Bug c++/108788] " pinskia at gcc dot gnu.org 2023-05-19 18:24 ` ppalka at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-108788-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).