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

* [Bug c++/51382] Incorrect diagnostic "cannot appear in a constant-expression"
  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 ` paolo.carlini at oracle dot com
  2011-12-01 22:40 ` dnovillo at google dot com
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-12-01 22:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-12-01 22:19:10 UTC ---
PR51319 (or PRs referenced therein) ?


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

* [Bug c++/51382] Incorrect diagnostic "cannot appear in a constant-expression"
  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
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: dnovillo at google dot com @ 2011-12-01 22:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from dnovillo at google dot com <dnovillo at google dot com> 2011-12-01 22:39:02 UTC ---
On Thu, Dec 1, 2011 at 17:19, paolo.carlini at oracle dot com
<gcc-bugzilla@gcc.gnu.org> wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51382
>
> --- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-12-01 22:19:10 UTC ---
> PR51319 (or PRs referenced therein) ?

Sorry?


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

* [Bug c++/51382] Incorrect diagnostic "cannot appear in a constant-expression"
  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
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-12-01 23:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-12-01 23:14:05 UTC ---
Diego, I'm pretty sure this is a dup of PR51319.


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

* [Bug c++/51382] Incorrect diagnostic "cannot appear in a constant-expression"
  2011-12-01 15:29 [Bug c++/51382] New: Incorrect diagnostic "cannot appear in a constant-expression" dnovillo at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  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
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-12-01 23:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-12-01 23:19:05 UTC ---
About the garbled error message - the second issue - the fix should be rather
trivial, just matter of handling USING_DECL in dump_expr together with the
other *_DECL and forwarding to dump_decl.


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

* [Bug c++/51382] Incorrect diagnostic "cannot appear in a constant-expression"
  2011-12-01 15:29 [Bug c++/51382] New: Incorrect diagnostic "cannot appear in a constant-expression" dnovillo at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: fabien at gcc dot gnu.org @ 2011-12-01 23:44 UTC (permalink / raw)
  To: gcc-bugs

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

fabien at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2011-12-01
                 CC|                            |fabien at gcc dot gnu.org
         AssignedTo|unassigned at gcc dot       |fabien at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1

--- Comment #5 from fabien at gcc dot gnu.org 2011-12-01 23:43:15 UTC ---
I am testing a fix. Paolo, thanks for retrieving the duplicate. Diego, this is
the one I was talking about (off list).


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

* [Bug c++/51382] Incorrect diagnostic "cannot appear in a constant-expression"
  2011-12-01 15:29 [Bug c++/51382] New: Incorrect diagnostic "cannot appear in a constant-expression" dnovillo at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: fabien at gcc dot gnu.org @ 2011-12-02  7:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from fabien at gcc dot gnu.org 2011-12-02 07:34:52 UTC ---
(In reply to comment #4)
> About the garbled error message - the second issue - the fix should be rather
> trivial, just matter of handling USING_DECL in dump_expr together with the
> other *_DECL and forwarding to dump_decl.

Although that seems quite simple, I think we'd need an invalid testcase showing
that this change is necessary. In this PR, the testcase is a valid code.


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

* [Bug c++/51382] Incorrect diagnostic "cannot appear in a constant-expression"
  2011-12-01 15:29 [Bug c++/51382] New: Incorrect diagnostic "cannot appear in a constant-expression" dnovillo at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  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
  8 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-12-02 10:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-12-02 10:13:02 UTC ---
Sure, agreed on that.


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

* [Bug c++/51382] Incorrect diagnostic "cannot appear in a constant-expression"
  2011-12-01 15:29 [Bug c++/51382] New: Incorrect diagnostic "cannot appear in a constant-expression" dnovillo at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  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
  8 siblings, 0 replies; 10+ messages in thread
From: fabien at gcc dot gnu.org @ 2011-12-04 22:10 UTC (permalink / raw)
  To: gcc-bugs

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

fabien at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marc.glisse at normalesup
                   |                            |dot org

--- Comment #8 from fabien at gcc dot gnu.org 2011-12-04 22:07:45 UTC ---
*** Bug 51319 has been marked as a duplicate of this bug. ***


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

* [Bug c++/51382] Incorrect diagnostic "cannot appear in a constant-expression"
  2011-12-01 15:29 [Bug c++/51382] New: Incorrect diagnostic "cannot appear in a constant-expression" dnovillo at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2011-12-04 22:10 ` fabien at gcc dot gnu.org
@ 2011-12-05 22:13 ` fabien at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: fabien at gcc dot gnu.org @ 2011-12-05 22:13 UTC (permalink / raw)
  To: gcc-bugs

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

fabien at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #9 from fabien at gcc dot gnu.org 2011-12-05 22:13:19 UTC ---
Fixed in r182029.


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