Bug 58611 - [4.8/4.9/4.10 Regression] [c++11] ICE with invalid constexpr constructor used in array initialization
Summary: [4.8/4.9/4.10 Regression] [c++11] ICE with invalid constexpr constructor used...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.9.0
: P5 normal
Target Milestone: 5.0
Assignee: Jason Merrill
URL:
Keywords: error-recovery, ice-on-invalid-code
Depends on:
Blocks: constexpr
  Show dependency treegraph
 
Reported: 2013-10-03 21:41 UTC by Volker Reichelt
Modified: 2014-07-14 05:27 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.5.0, 4.6.0, 4.7.0, 4.7.1, 4.7.2
Known to fail: 4.7.3, 4.8.0, 4.9.0
Last reconfirmed: 2014-02-03 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2013-10-03 21:41:04 UTC
The following invalid code snippet (compiled with "-std=c++11") triggers an ICE since GCC 4.7.3:

=============================
struct A
{
  int i;
  constexpr A() {}
};

struct B
{
  A a;
};

constexpr B b[] = { {} };
=============================

bug.cc: In constructor 'constexpr A::A()':
bug.cc:4:18: error: uninitialized member 'A::i' in 'constexpr' constructor
   constexpr A() {}
                  ^
bug.cc: At global scope:
bug.cc:12:24: internal compiler error: in reshape_init_r, at cp/decl.c:5434
 constexpr B b[] = { {} };
                        ^
0x5564f9 reshape_init_r
        ../../gcc/gcc/cp/decl.c:5434
0x556812 reshape_init_array_1
        ../../gcc/gcc/cp/decl.c:5102
0x5558b9 reshape_init(tree_node*, tree_node*, int)
        ../../gcc/gcc/cp/decl.c:5489
0x6bdeb8 finish_compound_literal(tree_node*, tree_node*, int)
        ../../gcc/gcc/cp/semantics.c:2481
0x557ccb check_initializer
        ../../gcc/gcc/cp/decl.c:5707
0x56a2ec cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
        ../../gcc/gcc/cp/decl.c:6347
0x65119f cp_parser_init_declarator
        ../../gcc/gcc/cp/parser.c:16568
0x6518bf cp_parser_simple_declaration
        ../../gcc/gcc/cp/parser.c:10986
0x653740 cp_parser_block_declaration
        ../../gcc/gcc/cp/parser.c:10867
0x65c76e cp_parser_declaration
        ../../gcc/gcc/cp/parser.c:10764
0x65b4da cp_parser_declaration_seq_opt
        ../../gcc/gcc/cp/parser.c:10650
0x65cda6 cp_parser_translation_unit
        ../../gcc/gcc/cp/parser.c:3939
0x65cda6 c_parse_file()
        ../../gcc/gcc/cp/parser.c:28900
0x7707e3 c_common_parse_file()
        ../../gcc/gcc/c-family/c-opts.c:1046
Please submit a full bug report, [etc.]
Comment 1 Richard Biener 2014-06-12 13:42:38 UTC
The 4.7 branch is being closed, moving target milestone to 4.8.4.
Comment 2 Jason Merrill 2014-07-14 05:26:03 UTC
Author: jason
Date: Mon Jul 14 05:25:31 2014
New Revision: 212506

URL: https://gcc.gnu.org/viewcvs?rev=212506&root=gcc&view=rev
Log:
	PR c++/58611
	* decl.c (check_initializer): Don't finish_compound_literal
	on erroneous constexpr init.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-array6.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl.c
Comment 3 Jason Merrill 2014-07-14 05:27:20 UTC
Fixed on trunk.