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

             Bug #: 51382
           Summary: Incorrect diagnostic "cannot appear in a
                    constant-expression"
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: dnovi...@gcc.gnu.org
                CC: cr...@google.com, fabien.ch...@gmail.com,
                    ja...@redhat.com


$ cat a.cc
template< int Value >
struct Base
{
   enum { b_e = Value };
};

template< typename Type >
struct Derived : Type
{
   Type::b_e;
   enum { d_e = b_e };
};

int v = (int)Derived< Base< 3 > >::d_e;

$ ./g++ -c a.cc
a.cc: In instantiation of 'struct Derived<Base<3> >':
a.cc:14:34:   required from here
a.cc:11:9: error: 'using Base<3>::b_e' cannot appear in a constant-expression

$ ./g++ --version
g++ (GCC) 4.7.0 20111128 (experimental)
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

There is an additional, possibly related, bug in the diagnostic.  This is not
exposed in this test case, but it shows up in the original source.
In another line of the same file, the following diagnostic is emitted:


file.h:1061:6: error: no match for 'operator*' in '2 * #'using_decl' not
supported by dump_expr#<expression error>'.  The code reads:

template<class X>
char Set<X>::fbs_[2 * k];


it's not clear to me whether the code is well-formed or not, but the diagnostic
should certainly not get all confused like that.

Lawrence, could you get a reproducer for this diagnostic?


Thanks.  Diego.

Reply via email to