public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/54875] New: Forward declare enums cannot be used as a template argument
@ 2012-10-09 13:39 public at alisdairm dot net
  2012-10-09 14:23 ` [Bug c++/54875] " daniel.kruegler at googlemail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: public at alisdairm dot net @ 2012-10-09 13:39 UTC (permalink / raw)
  To: gcc-bugs


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<typename T>
using AddConst = T const;

enum FwdEnum : int;

int main() {
   AddConst<FwdEnum> *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<FwdEnum> *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)


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-11-16 15:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-09 13:39 [Bug c++/54875] New: Forward declare enums cannot be used as a template argument public at alisdairm dot net
2012-10-09 14:23 ` [Bug c++/54875] " daniel.kruegler at googlemail dot com
2012-10-09 14:38 ` paolo.carlini at oracle dot com
2012-10-26 18:50 ` dodji at gcc dot gnu.org
2012-11-16 12:57 ` dodji at seketeli dot org
2012-11-16 15:20 ` dodji at gcc dot gnu.org
2012-11-16 15:23 ` dodji at gcc dot gnu.org

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).