public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/59838] New: ICE with an enum using an incomplete type
@ 2014-01-16  7:01 ville.voutilainen at gmail dot com
  2014-01-16 10:29 ` [Bug c++/59838] " mpolacek at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: ville.voutilainen at gmail dot com @ 2014-01-16  7:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 59838
           Summary: ICE with an enum using an incomplete type
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ville.voutilainen at gmail dot com

Very simple test:

enum E { a, b = true ? 1 : ((E)a, 0) };

enumcrash.cpp:1:32: internal compiler error: Segmentation fault
 enum E { a, b = true ? 1 : ((E)a, 0) };
                                ^
0xb46faf crash_signal
    ../../gcc/toplev.c:336
0xd65d54 int_fits_type_p(tree_node const*, tree_node const*)
    ../../gcc/tree.c:8566
0x69b53b ocp_convert(tree_node*, tree_node*, int, int, int)
    ../../gcc/cp/cvt.c:756
0x6992e7 cp_build_c_cast(tree_node*, tree_node*, int)
    ../../gcc/cp/typeck.c:7130
0x6565ef cp_parser_binary_expression
    ../../gcc/cp/parser.c:7874
0x656ae1 cp_parser_assignment_expression
    ../../gcc/cp/parser.c:8112
0x658a74 cp_parser_expression
    ../../gcc/cp/parser.c:8274
0x64fe0f cp_parser_primary_expression
    ../../gcc/cp/parser.c:4279
0x65288a cp_parser_postfix_expression
    ../../gcc/cp/parser.c:5969
0x655948 cp_parser_unary_expression
    ../../gcc/cp/parser.c:7170
0x6565ef cp_parser_binary_expression
    ../../gcc/cp/parser.c:7874
0x656ae1 cp_parser_assignment_expression
    ../../gcc/cp/parser.c:8112
0x656dc3 cp_parser_assignment_expression
    ../../gcc/cp/parser.c:8162
0x656dc3 cp_parser_question_colon_clause
    ../../gcc/cp/parser.c:8073
0x656dc3 cp_parser_assignment_expression
    ../../gcc/cp/parser.c:8116
0x656f43 cp_parser_assignment_expression
    ../../gcc/cp/parser.c:8162
0x656f43 cp_parser_constant_expression
    ../../gcc/cp/parser.c:8372
0x65fe12 cp_parser_enumerator_definition
    ../../gcc/cp/parser.c:15634
0x65fe12 cp_parser_enumerator_list
    ../../gcc/cp/parser.c:15581
0x65fe12 cp_parser_enum_specifier
    ../../gcc/cp/parser.c:15507
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.


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

* [Bug c++/59838] ICE with an enum using an incomplete type
  2014-01-16  7:01 [Bug c++/59838] New: ICE with an enum using an incomplete type ville.voutilainen at gmail dot com
@ 2014-01-16 10:29 ` mpolacek at gcc dot gnu.org
  2014-01-17  9:55 ` mpolacek at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-01-16 10:29 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-01-16
                 CC|                            |mpolacek at gcc dot gnu.org
   Target Milestone|---                         |4.7.4
     Ever confirmed|0                           |1

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.  Even GCC 4.6 ICEs, g++34 says:
ee.C:1: error: invalid use of undefined type `enum E'
ee.C:1: error: forward declaration of `enum E'
ee.C:1: error: a comma operator cannot appear in a constant-expression
ee.C:1: error: enumerator value for `b' not integer constant


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

* [Bug c++/59838] ICE with an enum using an incomplete type
  2014-01-16  7:01 [Bug c++/59838] New: ICE with an enum using an incomplete type ville.voutilainen at gmail dot com
  2014-01-16 10:29 ` [Bug c++/59838] " mpolacek at gcc dot gnu.org
@ 2014-01-17  9:55 ` mpolacek at gcc dot gnu.org
  2014-01-17 10:40 ` ville.voutilainen at gmail dot com
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-01-17  9:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
This seems to fix it.

--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -753,6 +753,7 @@ ocp_convert (tree type, tree expr, int convtype, int flags,
             unspecified.  */
          if ((complain & tf_warning)
              && TREE_CODE (e) == INTEGER_CST
+             && ENUM_UNDERLYING_TYPE (type)
              && !int_fits_type_p (e, ENUM_UNDERLYING_TYPE (type)))
            warning_at (loc, OPT_Wconversion, 
                        "the result of the conversion is unspecified because "


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

* [Bug c++/59838] ICE with an enum using an incomplete type
  2014-01-16  7:01 [Bug c++/59838] New: ICE with an enum using an incomplete type ville.voutilainen at gmail dot com
  2014-01-16 10:29 ` [Bug c++/59838] " mpolacek at gcc dot gnu.org
  2014-01-17  9:55 ` mpolacek at gcc dot gnu.org
@ 2014-01-17 10:40 ` ville.voutilainen at gmail dot com
  2014-01-17 10:45 ` mpolacek at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ville.voutilainen at gmail dot com @ 2014-01-17 10:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Ville Voutilainen <ville.voutilainen at gmail dot com> ---
Ok, but the patch needs to be massaged a bit to give an error in the case where
the underlying type is not set, if the complain flag has error set. I can do
that, seems simple enough.


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

* [Bug c++/59838] ICE with an enum using an incomplete type
  2014-01-16  7:01 [Bug c++/59838] New: ICE with an enum using an incomplete type ville.voutilainen at gmail dot com
                   ` (2 preceding siblings ...)
  2014-01-17 10:40 ` ville.voutilainen at gmail dot com
@ 2014-01-17 10:45 ` mpolacek at gcc dot gnu.org
  2014-01-17 10:51 ` mpolacek at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-01-17 10:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
With the patch cc1plus says:

ee.C:1:32: error: conversion to incomplete type
 enum E { a, b = true ? 1 : ((E)a, 0) };
                                ^
ee.C:1:33: error: a comma operator cannot appear in a constant-expression
 enum E { a, b = true ? 1 : ((E)a, 0) };
                                 ^


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

* [Bug c++/59838] ICE with an enum using an incomplete type
  2014-01-16  7:01 [Bug c++/59838] New: ICE with an enum using an incomplete type ville.voutilainen at gmail dot com
                   ` (3 preceding siblings ...)
  2014-01-17 10:45 ` mpolacek at gcc dot gnu.org
@ 2014-01-17 10:51 ` mpolacek at gcc dot gnu.org
  2014-01-17 10:58 ` [Bug c++/59838] [4.7/4.8/4.9 Regression] " mpolacek at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-01-17 10:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Yep, I only need to do some further testing/bootstrap.


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

* [Bug c++/59838] [4.7/4.8/4.9 Regression] ICE with an enum using an incomplete type
  2014-01-16  7:01 [Bug c++/59838] New: ICE with an enum using an incomplete type ville.voutilainen at gmail dot com
                   ` (4 preceding siblings ...)
  2014-01-17 10:51 ` mpolacek at gcc dot gnu.org
@ 2014-01-17 10:58 ` mpolacek at gcc dot gnu.org
  2014-01-17 11:16 ` mpolacek at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-01-17 10:58 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |mpolacek at gcc dot gnu.org
            Summary|ICE with an enum using an   |[4.7/4.8/4.9 Regression]
                   |incomplete type             |ICE with an enum using an
                   |                            |incomplete type

--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
That's BTW what gcc 4.0.2 issued.

Mine.


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

* [Bug c++/59838] [4.7/4.8/4.9 Regression] ICE with an enum using an incomplete type
  2014-01-16  7:01 [Bug c++/59838] New: ICE with an enum using an incomplete type ville.voutilainen at gmail dot com
                   ` (5 preceding siblings ...)
  2014-01-17 10:58 ` [Bug c++/59838] [4.7/4.8/4.9 Regression] " mpolacek at gcc dot gnu.org
@ 2014-01-17 11:16 ` mpolacek at gcc dot gnu.org
  2014-01-17 15:23 ` mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-01-17 11:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
A few bytes shorter testcase

enum E { a, b = (E) a };


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

* [Bug c++/59838] [4.7/4.8/4.9 Regression] ICE with an enum using an incomplete type
  2014-01-16  7:01 [Bug c++/59838] New: ICE with an enum using an incomplete type ville.voutilainen at gmail dot com
                   ` (6 preceding siblings ...)
  2014-01-17 11:16 ` mpolacek at gcc dot gnu.org
@ 2014-01-17 15:23 ` mpolacek at gcc dot gnu.org
  2014-01-20 10:43 ` [Bug c++/59838] [4.7/4.8 " mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-01-17 15:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Author: mpolacek
Date: Fri Jan 17 15:23:17 2014
New Revision: 206716

URL: http://gcc.gnu.org/viewcvs?rev=206716&root=gcc&view=rev
Log:
    PR c++/59838
cp/
    * cvt.c (ocp_convert): Don't segfault on non-existing
    ENUM_UNDERLYING_TYPE.
testsuite/
    * g++.dg/diagnostic/pr59838.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/diagnostic/pr59838.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cvt.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/59838] [4.7/4.8 Regression] ICE with an enum using an incomplete type
  2014-01-16  7:01 [Bug c++/59838] New: ICE with an enum using an incomplete type ville.voutilainen at gmail dot com
                   ` (7 preceding siblings ...)
  2014-01-17 15:23 ` mpolacek at gcc dot gnu.org
@ 2014-01-20 10:43 ` mpolacek at gcc dot gnu.org
  2014-01-20 10:45 ` [Bug c++/59838] [4.7 " mpolacek at gcc dot gnu.org
  2014-01-27 19:08 ` jason at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-01-20 10:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Author: mpolacek
Date: Mon Jan 20 10:42:29 2014
New Revision: 206795

URL: http://gcc.gnu.org/viewcvs?rev=206795&root=gcc&view=rev
Log:
    PR c++/59838
cp/
    * cvt.c (ocp_convert): Don't segfault on non-existing
    ENUM_UNDERLYING_TYPE.
testsuite/
    * g++.dg/diagnostic/pr59838.C: New test.

Added:
    branches/gcc-4_8-branch/gcc/testsuite/g++.dg/diagnostic/pr59838.C
Modified:
    branches/gcc-4_8-branch/gcc/cp/ChangeLog
    branches/gcc-4_8-branch/gcc/cp/cvt.c
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog


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

* [Bug c++/59838] [4.7 Regression] ICE with an enum using an incomplete type
  2014-01-16  7:01 [Bug c++/59838] New: ICE with an enum using an incomplete type ville.voutilainen at gmail dot com
                   ` (8 preceding siblings ...)
  2014-01-20 10:43 ` [Bug c++/59838] [4.7/4.8 " mpolacek at gcc dot gnu.org
@ 2014-01-20 10:45 ` mpolacek at gcc dot gnu.org
  2014-01-27 19:08 ` jason at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-01-20 10:45 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
            Summary|[4.7/4.8 Regression] ICE    |[4.7 Regression] ICE with
                   |with an enum using an       |an enum using an incomplete
                   |incomplete type             |type

--- Comment #11 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.  (Not backporting it to 4.7.)


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

* [Bug c++/59838] [4.7 Regression] ICE with an enum using an incomplete type
  2014-01-16  7:01 [Bug c++/59838] New: ICE with an enum using an incomplete type ville.voutilainen at gmail dot com
                   ` (9 preceding siblings ...)
  2014-01-20 10:45 ` [Bug c++/59838] [4.7 " mpolacek at gcc dot gnu.org
@ 2014-01-27 19:08 ` jason at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2014-01-27 19:08 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |cas43 at cs dot stanford.edu

--- Comment #12 from Jason Merrill <jason at gcc dot gnu.org> ---
*** Bug 57946 has been marked as a duplicate of this bug. ***


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

end of thread, other threads:[~2014-01-27 19:08 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-16  7:01 [Bug c++/59838] New: ICE with an enum using an incomplete type ville.voutilainen at gmail dot com
2014-01-16 10:29 ` [Bug c++/59838] " mpolacek at gcc dot gnu.org
2014-01-17  9:55 ` mpolacek at gcc dot gnu.org
2014-01-17 10:40 ` ville.voutilainen at gmail dot com
2014-01-17 10:45 ` mpolacek at gcc dot gnu.org
2014-01-17 10:51 ` mpolacek at gcc dot gnu.org
2014-01-17 10:58 ` [Bug c++/59838] [4.7/4.8/4.9 Regression] " mpolacek at gcc dot gnu.org
2014-01-17 11:16 ` mpolacek at gcc dot gnu.org
2014-01-17 15:23 ` mpolacek at gcc dot gnu.org
2014-01-20 10:43 ` [Bug c++/59838] [4.7/4.8 " mpolacek at gcc dot gnu.org
2014-01-20 10:45 ` [Bug c++/59838] [4.7 " mpolacek at gcc dot gnu.org
2014-01-27 19:08 ` jason 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).