http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51143

             Bug #: 51143
           Summary: [C++11][DR1159] Alias template allows class definition
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: daniel.krueg...@googlemail.com
                CC: ja...@redhat.com


gcc 4.7.0 20111112 (experimental) in C++11 mode accepts the following program
(if variable a2 is commented out):

//---
template<int N>
using A1 = struct B1 { static auto constexpr value = N; };

A1<0> a1;

template<class T>
using A2 = struct B2 { void f(T){} };

A2<bool> a2; // Causes ICE

int main() { } // Line 11
//---

If a2 is commented in (as shown) an ICE is produced:

"main.cpp|11|internal compiler error: in is_base_type, at dwarf2out.c:9643"

According to 7.1.6 [dcl.type] p3 both alias template definitions should be
rejected:

"A type-specifier-seq shall not define a class or enumeration unless it
appears in the type-id of an alias-declaration (7.1.3) that is not the
declaration of a template-declaration."

This sentence was added to honor NB comment US 74 via:

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1159

The current implementation correctly rejects enumeration definitions and
unnamed class definitions, though.

Reply via email to