From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15871 invoked by alias); 9 Oct 2012 13:39:27 -0000 Received: (qmail 14738 invoked by uid 48); 9 Oct 2012 13:39:11 -0000 From: "public at alisdairm dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/54875] New: Forward declare enums cannot be used as a template argument Date: Tue, 09 Oct 2012 13:39: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: normal X-Bugzilla-Who: public at alisdairm dot net 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" 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-10/txt/msg00818.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54875 Bug #: 54875 Summary: Forward declare enums cannot be used as a template argument Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: public@alisdairm.net The following simple code snippet shows the problem: template using AddConst = T const; enum FwdEnum : int; int main() { AddConst *ptr = nullptr; } Trying to instantiate the alias template, in this case to declare a pointer but the problem is more general, produces an internal compiler error. The problem is probably older than the gcc 4.8 I am testing with, but it does give a nice assertion from the compiler: main.cpp: In function 'int main()': main.cpp:7:20: internal compiler error: tree check: expected enumeral_type, have template_type_parm in tsubst_enum, at cp/pt.c:18923 AddConst *ptr = nullptr; ^ main.cpp:7:20: internal compiler error: Abort trap: 6 g++-mp-4.8: internal compiler error: Abort trap: 6 (program cc1plus) Abort trap: 6 Version info of the compiler I am testing with: gcc -v -save-temps -std=c++11 Using built-in specs. Target: i686-apple-darwin11 Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~28/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~28/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1 Thread model: posix gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)