public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "ing.russomauro at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/114694] New: dependent-name alias type accepted in elaborated type specifier within a template Date: Thu, 11 Apr 2024 14:21:34 +0000 [thread overview] Message-ID: <bug-114694-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114694 Bug ID: 114694 Summary: dependent-name alias type accepted in elaborated type specifier within a template Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ing.russomauro at gmail dot com Target Milestone: --- Here below you may find an example with a class named D, defining a nested alias type which, in turn, is referred by an elaborated type specifier within a function template f() instantiated with template type parameter equal to D. The same with a class E where 'using' syntax is used. In both cases, the alias-id is accepted. The non-dependent alias-id ('Alias') is correctly refused. The standard reads "If a typedef-name is used to identify the subject of an elaborated-type-specifier ..., the program is ill-formed." I see old tickets about elaborated-type-specifiers, as 11036, and 87781, and a single open ticket 55809, but none of them seem related to the context of a dependent-name alias within a template. class C{public: void f(){};}; using Alias = C; struct D { typedef C Alias2; }; struct E { using Alias2 = C; }; template<class T> void f() { //struct Alias x; -> error, as 'Alias' is an alias type struct T::Alias2 y; // WEIRDLY, no error here, despite 'Alias2' is // an alias type when instantiated with either T=D or T=E. y.f(); // avoids warning for unused variable typename T::Alias2 z; // ok no error with typename z.f(); // avoids warning for unused variable } void foo() { //struct Alias a; -> error, as 'Alias' is an alias type //struct D::Alias2 a2; -> error, as 'D::Alias2' is an alias type f<D>(); f<E>(); } int main(){ foo(); }
next reply other threads:[~2024-04-11 14:21 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-04-11 14:21 ing.russomauro at gmail dot com [this message] 2024-04-11 20:22 ` [Bug c++/114694] " pinskia at gcc dot gnu.org 2024-04-11 20:27 ` pinskia at gcc dot gnu.org 2024-04-11 20:30 ` pinskia at gcc dot gnu.org 2024-04-11 21:11 ` pinskia 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-114694-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).