Bug 58610 - [4.7/4.8/4.9 Regression] [c++11] ICE with constexpr of class with template constructor
Summary: [4.7/4.8/4.9 Regression] [c++11] ICE with constexpr of class with template co...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.9.0
: P5 normal
Target Milestone: 4.9.0
Assignee: Not yet assigned to anyone
URL:
Keywords: error-recovery, ice-on-invalid-code
Depends on:
Blocks: constexpr
  Show dependency treegraph
 
Reported: 2013-10-03 21:29 UTC by Volker Reichelt
Modified: 2014-02-28 20:21 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work: 4.6.0
Known to fail: 4.7.0, 4.8.0, 4.9.0
Last reconfirmed: 2014-02-27 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:29:47 UTC
The following invalid code snippet (compiled with "-std=c++11") triggers an ICE since GCC 4.7.0:

=============================
struct A
{
  template<typename> A();
};

constexpr A a;
=============================

bug.cc:6:13: error: the type 'const A' of constexpr variable 'a' is not literal
 constexpr A a;
             ^
bug.cc:1:8: note: 'A' is not literal because:
 struct A
        ^
bug.cc:1:8: note:   'A' is not an aggregate, does not have a trivial default constructor, and has no constexpr constructor that is not a copy or move constructor
bug.cc:6:13: internal compiler error: tree check: expected function_decl, have template_decl in explain_non_literal_class, at cp/class.c:5327
 constexpr A a;
             ^
0xcd83ea tree_check_failed(tree_node const*, char const*, int, char const*, ...)
        ../../gcc/gcc/tree.c:9176
0x5f099c tree_check
        ../../gcc/gcc/tree.h:2609
0x5f099c explain_non_literal_class(tree_node*)
        ../../gcc/gcc/cp/class.c:5327
0x6bf46b ensure_literal_type_for_constexpr_object(tree_node*)
        ../../gcc/gcc/cp/semantics.c:5814
0x5696fb cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
        ../../gcc/gcc/cp/decl.c:6157
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 Paolo Carlini 2014-02-27 18:36:50 UTC
Mine.
Comment 2 paolo@gcc.gnu.org 2014-02-28 20:20:53 UTC
Author: paolo
Date: Fri Feb 28 20:20:21 2014
New Revision: 208226

URL: http://gcc.gnu.org/viewcvs?rev=208226&root=gcc&view=rev
Log:
/cp
2014-02-28  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/58610
	* cp-tree.h (DECL_DELETED_FN): Use LANG_DECL_FN_CHECK.
	* call.c (print_z_candidate): Remove STRIP_TEMPLATE use.
	* lambda.c (maybe_add_lambda_conv_op): Likewise.

/testsuite
2014-02-28  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/58610
	* g++.dg/cpp0x/constexpr-ice11.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-ice11.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/lambda.c
    trunk/gcc/testsuite/ChangeLog
Comment 3 Paolo Carlini 2014-02-28 20:21:31 UTC
Fixed for 4.9.0.