From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5846 invoked by alias); 18 Aug 2012 05:16:19 -0000 Received: (qmail 5837 invoked by uid 22791); 18 Aug 2012 05:16:17 -0000 X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_CX X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 18 Aug 2012 05:16:03 +0000 From: "paul at preney dot ca" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: major X-Bugzilla-Who: paul at preney dot ca X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-08/txt/msg01206.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D54309 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=3D28046 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=3Dc++11 gcc-cxx-bug.cxx=20 gcc-cxx-bug.cxx: In instantiation of =E2=80=98void func() [with T =3D int]= =E2=80=99: gcc-cxx-bug.cxx:25:13: required from here gcc-cxx-bug.cxx:15:24: error: no type named =E2=80=98Stuff=E2=80=99 in =E2= =80=98using test =3D class Foo=E2=80=99 typename test::Stuff b =3D test::Stuff::beta; // not ok: BUG ^ gcc-cxx-bug.cxx:15:24: error: no type named =E2=80=98Stuff=E2=80=99 in =E2= =80=98using test =3D class Foo=E2=80=99 gcc-cxx-bug.cxx:15:24: error: no type named =E2=80=98Stuff=E2=80=99 in =E2= =80=98using test =3D class Foo=E2=80=99 $ (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::Stuff" in the example) when the class template parameter is not hard-coded using the using type alias (i.e., Foo is used but Foo is okay). The code triggering the issue follows and is attached. template class Foo { public: enum class Stuff { alpha, beta }; }; template void func() { typename Foo::Stuff a =3D Foo::Stuff::alpha; // ok a =3D a; using test =3D Foo; typename test::Stuff b =3D test::Stuff::beta; // not ok: BUG b =3D b; typedef Foo test2; typename test2::Stuff c =3D test2::Stuff::beta; // ok c =3D c; } int main() { func(); { Foo::Stuff a =3D Foo::Stuff::alpha; // ok a =3D a; using test =3D Foo; typename test::Stuff b =3D test::Stuff::beta; // ok b =3D b; typedef Foo test2; typename test2::Stuff c =3D test2::Stuff::beta; // ok c =3D c; } }