public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51382] New: Incorrect diagnostic "cannot appear in a constant-expression"
@ 2011-12-01 15:29 dnovillo at gcc dot gnu.org
  2011-12-01 22:19 ` [Bug c++/51382] " paolo.carlini at oracle dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: dnovillo at gcc dot gnu.org @ 2011-12-01 15:29 UTC (permalink / raw)
  To: gcc-bugs

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: unassigned@gcc.gnu.org
        ReportedBy: dnovillo@gcc.gnu.org
                CC: crowl@google.com, fabien.chene@gmail.com,
                    jason@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.


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

end of thread, other threads:[~2011-12-05 22:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-01 15:29 [Bug c++/51382] New: Incorrect diagnostic "cannot appear in a constant-expression" dnovillo at gcc dot gnu.org
2011-12-01 22:19 ` [Bug c++/51382] " paolo.carlini at oracle dot com
2011-12-01 22:40 ` dnovillo at google dot com
2011-12-01 23:14 ` paolo.carlini at oracle dot com
2011-12-01 23:19 ` paolo.carlini at oracle dot com
2011-12-01 23:44 ` fabien at gcc dot gnu.org
2011-12-02  7:36 ` fabien at gcc dot gnu.org
2011-12-02 10:14 ` paolo.carlini at oracle dot com
2011-12-04 22:10 ` fabien at gcc dot gnu.org
2011-12-05 22:13 ` fabien 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).