Bug 58511 - [4.8/4.9/4.10 Regression] [c++11] ICE using static const member variable in constexpr
Summary: [4.8/4.9/4.10 Regression] [c++11] ICE using static const member variable in c...
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-09-23 19:52 UTC by Volker Reichelt
Modified: 2014-07-14 05:26 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.8.0, 4.9.0
Last reconfirmed: 2013-09-24 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-09-23 19:52:57 UTC
The following invalid code snippet (compiled with "-std=c++0x") triggers an ICE since GCC 4.8.0 (when inheriting constructors were introduced):

====================================
struct A
{
  constexpr A(int, int = i) {}
  static const int i;
};

struct B : A
{
  using A::A;
};

constexpr B b(0);
====================================

bug.cc:12:16: error: 'constexpr B::B(int)' called in a constant expression
 constexpr B b(0);
                ^
bug.cc:9:12: note: 'constexpr B::B(int)' is not usable as a constexpr function because:
   using A::A;
            ^
bug.cc:9:12: internal compiler error: in synthesized_method_walk, at cp/method.c:1218
0x675548 synthesized_method_walk
        ../../gcc-4.8.0/gcc/cp/method.c:1217
0x679692 explain_implicit_non_constexpr(tree_node*)
        ../../gcc-4.8.0/gcc/cp/method.c:1481
0x69f68b explain_invalid_constexpr_fn(tree_node*)
        ../../gcc-4.8.0/gcc/cp/semantics.c:6379
0x69faf6 cxx_eval_call_expression
        ../../gcc-4.8.0/gcc/cp/semantics.c:6751
0x6a1142 cxx_eval_constant_expression
        ../../gcc-4.8.0/gcc/cp/semantics.c:7814
0x6a14a9 cxx_eval_constant_expression
        ../../gcc-4.8.0/gcc/cp/semantics.c:7835
0x6a4426 cxx_eval_outermost_constant_expr
        ../../gcc-4.8.0/gcc/cp/semantics.c:8115
0x5bd69d store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, int)
        ../../gcc-4.8.0/gcc/cp/typeck2.c:722
0x540b40 check_initializer
        ../../gcc-4.8.0/gcc/cp/decl.c:5711
0x5537b5 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
        ../../gcc-4.8.0/gcc/cp/decl.c:6328
0x62afeb cp_parser_init_declarator
        ../../gcc-4.8.0/gcc/cp/parser.c:16038
0x62b85e cp_parser_simple_declaration
        ../../gcc-4.8.0/gcc/cp/parser.c:10567
0x62d630 cp_parser_block_declaration
        ../../gcc-4.8.0/gcc/cp/parser.c:10448
0x6361fb cp_parser_declaration
        ../../gcc-4.8.0/gcc/cp/parser.c:10345
0x634ecd cp_parser_declaration_seq_opt
        ../../gcc-4.8.0/gcc/cp/parser.c:10231
0x636772 cp_parser_translation_unit
        ../../gcc-4.8.0/gcc/cp/parser.c:3807
0x636772 c_parse_file()
        ../../gcc-4.8.0/gcc/cp/parser.c:28186
0x73e504 c_common_parse_file()
        ../../gcc-4.8.0/gcc/c-family/c-opts.c:1046
Please submit a full bug report, [etc.]
Comment 1 Marek Polacek 2013-09-24 16:52:41 UTC
Confirmed with trunk, I don't see the ICE with 4.8.2.
Comment 2 Paolo Carlini 2014-03-04 11:04:04 UTC
Maybe just a STRIP_TEMPLATE issue. Looking into it.
Comment 3 Paolo Carlini 2014-03-04 11:05:08 UTC
Sorry, I wanted to add to PR60389.
Comment 4 Jakub Jelinek 2014-04-22 11:36:11 UTC
GCC 4.9.0 has been released
Comment 5 Jason Merrill 2014-07-14 05:26:09 UTC
Author: jason
Date: Mon Jul 14 05:25:37 2014
New Revision: 212507

URL: https://gcc.gnu.org/viewcvs?rev=212507&root=gcc&view=rev
Log:
	PR c++/58511
	* semantics.c (is_instantiation_of_constexpr): Return true for
	defaulted functions, too.
	(explain_invalid_constexpr_fn): Only use
	explain_implicit_non_constexpr if !DECL_DECLARED_CONSTEXPR_P.
	* method.c (explain_implicit_non_constexpr): Pass
	DECL_INHERITED_CTOR_BASE to explain_implicit_non_constexpr.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-inhctor1.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/method.c
    trunk/gcc/cp/semantics.c
    trunk/gcc/testsuite/g++.dg/cpp0x/nsdmi3.C
Comment 6 Jason Merrill 2014-07-14 05:26:47 UTC
Fixed on trunk.