public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "paul at preney dot ca" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/54309] New: type alias accessing class template enum type member fails Date: Sat, 18 Aug 2012 05:16:00 -0000 [thread overview] Message-ID: <bug-54309-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54309 Bug #: 54309 Summary: type alias accessing class template enum type member fails Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: paul@preney.ca Created attachment 28046 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28046 Source code demonstrating the bug. This is easier to see not working than to describe. The code that does not work (i.e., "not ok: BUG" comment in the example) works if you replace the using type alias with a typedef instead though (which means that is a work-around for now). This bug was tested with these versions of GCC: g++ v4.7.0 g++ v4.8.0 (snapshot 20120812) The error message (from GCC v4.8): $ g++-4.8.0-alpha20120812 -std=c++11 gcc-cxx-bug.cxx gcc-cxx-bug.cxx: In instantiation of ‘void func() [with T = int]’: gcc-cxx-bug.cxx:25:13: required from here gcc-cxx-bug.cxx:15:24: error: no type named ‘Stuff’ in ‘using test = class Foo<T>’ typename test::Stuff b = test::Stuff::beta; // not ok: BUG ^ gcc-cxx-bug.cxx:15:24: error: no type named ‘Stuff’ in ‘using test = class Foo<T>’ gcc-cxx-bug.cxx:15:24: error: no type named ‘Stuff’ in ‘using test = class Foo<T>’ $ (I also tried this code with clang++ (v3.1) and it compiles successfully as expected.) It appears to only occur when a using type alias (i.e., the "test" alias in the example) is used to access a template class' member that is an enum type (i.e., "Foo<T>::Stuff" in the example) when the class template parameter is not hard-coded using the using type alias (i.e., Foo<T> is used but Foo<int> is okay). The code triggering the issue follows and is attached. template <typename T> class Foo { public: enum class Stuff { alpha, beta }; }; template <typename T> void func() { typename Foo<T>::Stuff a = Foo<T>::Stuff::alpha; // ok a = a; using test = Foo<T>; typename test::Stuff b = test::Stuff::beta; // not ok: BUG b = b; typedef Foo<T> test2; typename test2::Stuff c = test2::Stuff::beta; // ok c = c; } int main() { func<int>(); { Foo<int>::Stuff a = Foo<int>::Stuff::alpha; // ok a = a; using test = Foo<int>; typename test::Stuff b = test::Stuff::beta; // ok b = b; typedef Foo<int> test2; typename test2::Stuff c = test2::Stuff::beta; // ok c = c; } }
next reply other threads:[~2012-08-18 5:16 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-08-18 5:16 paul at preney dot ca [this message] 2012-08-18 6:02 ` [Bug c++/54309] [C++11] " pinskia at gcc dot gnu.org 2012-08-18 6:05 ` [Bug c++/54309] [C++11] type alias accessing class template typename pinskia at gcc dot gnu.org 2012-08-18 9:40 ` paolo.carlini at oracle dot com 2012-08-20 12:10 ` dodji at seketeli dot org 2012-08-20 12:12 ` paolo.carlini at oracle dot com 2013-05-03 9:54 ` paolo.carlini at oracle dot com
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-54309-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).