Bug 67687 - ICE initializing constexpr member with constexpr constructor
Summary: ICE initializing constexpr member with constexpr constructor
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: 6.4
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: constexpr
  Show dependency treegraph
 
Reported: 2015-09-22 23:48 UTC by Paolo G Crosetto
Modified: 2017-05-12 11:26 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.9.3, 5.3.0, 6.0
Last reconfirmed: 2016-03-15 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paolo G Crosetto 2015-09-22 23:48:09 UTC
the following code doesn't compile with gcc 5.1
error:
internal compiler error: unexpected expression '(const accessor_base){dimension<Pair:: first>{0}}' of kind implicit_conv_expr
     static constexpr accessor_base s_args_constexpr{dimension<Pair::first>{0} };

//CODE:
template <unsigned int Coordinate>
struct dimension{
    template<typename ... T>
    constexpr dimension(T...t){}
};

struct accessor_base{
    template<typename ... T>
    constexpr accessor_base(T...t){}
};

template <typename ArgType, typename Pair>
struct accessor_mixed{

private:
    static constexpr accessor_base s_args_constexpr{dimension<Pair::first>{0} };
};
Comment 1 Daniel Krügler 2015-09-26 16:59:05 UTC
Same problem in 6.0 trunk
Comment 2 Martin Sebor 2016-03-16 04:00:42 UTC
This seems to have always failed with an ICE.  Reconfirming for all supported versions, including the top of trunk.

$ cat t.c && /build/gcc-trunk-bootstrap/gcc/xgcc -B /build/gcc-trunk-bootstrap/gcc -S -Wall -Wextra -Wpedantic -xc++ t.c
template <unsigned int Coordinate>
struct dimension{
    template<typename ... T>
    constexpr dimension(T...t){}
};

struct accessor_base{
    template<typename ... T>
    constexpr accessor_base(T...t){}
};

template <typename ArgType, typename Pair>
struct accessor_mixed{

private:
    static constexpr accessor_base s_args_constexpr{dimension<Pair::first>{0} };
};
t.c:16:79: internal compiler error: unexpected expression ‘(const accessor_base){dimension<Pair:: first>{0}}’ of kind implicit_conv_expr
    static constexpr accessor_base s_args_constexpr{dimension<Pair::first>{0} };
                                                                              ^
0x84e015 cxx_eval_constant_expression
	/src/gcc/trunk/gcc/cp/constexpr.c:3968
0x8515d3 cxx_eval_outermost_constant_expr
	/src/gcc/trunk/gcc/cp/constexpr.c:4026
0x6d47b4 store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, int)
	/src/gcc/trunk/gcc/cp/typeck2.c:822
0x63be15 check_initializer
	/src/gcc/trunk/gcc/cp/decl.c:6155
0x65c1c8 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
	/src/gcc/trunk/gcc/cp/decl.c:6675
0x70bc0e grokfield(cp_declarator const*, cp_decl_specifier_seq*, tree_node*, bool, tree_node*, tree_node*)
	/src/gcc/trunk/gcc/cp/decl2.c:1036
0x758837 cp_parser_member_declaration
	/src/gcc/trunk/gcc/cp/parser.c:22559
0x734128 cp_parser_member_specification_opt
	/src/gcc/trunk/gcc/cp/parser.c:22108
0x734128 cp_parser_class_specifier_1
	/src/gcc/trunk/gcc/cp/parser.c:21300
0x734128 cp_parser_class_specifier
	/src/gcc/trunk/gcc/cp/parser.c:21536
0x734128 cp_parser_type_specifier
	/src/gcc/trunk/gcc/cp/parser.c:15820
0x748f01 cp_parser_decl_specifier_seq
	/src/gcc/trunk/gcc/cp/parser.c:12744
0x7573c5 cp_parser_single_declaration
	/src/gcc/trunk/gcc/cp/parser.c:25703
0x75776c cp_parser_template_declaration_after_parameters
	/src/gcc/trunk/gcc/cp/parser.c:25398
0x758178 cp_parser_explicit_template_declaration
	/src/gcc/trunk/gcc/cp/parser.c:25630
0x758178 cp_parser_template_declaration_after_export
	/src/gcc/trunk/gcc/cp/parser.c:25648
0x75f6a9 cp_parser_declaration
	/src/gcc/trunk/gcc/cp/parser.c:12080
0x75ded6 cp_parser_declaration_seq_opt
	/src/gcc/trunk/gcc/cp/parser.c:12010
0x75e1e8 cp_parser_translation_unit
	/src/gcc/trunk/gcc/cp/parser.c:4323
0x75e1e8 c_parse_file()
	/src/gcc/trunk/gcc/cp/parser.c:37394
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.
Comment 3 Paolo Carlini 2017-05-12 10:23:40 UTC
This is fixed in 7.1.0, I'm adding a testcase and closing the bug.
Comment 4 Paolo Carlini 2017-05-12 10:46:25 UTC
In fact it's fixed for 6.4.0 too.
Comment 5 paolo@gcc.gnu.org 2017-05-12 11:25:33 UTC
Author: paolo
Date: Fri May 12 11:24:56 2017
New Revision: 247964

URL: https://gcc.gnu.org/viewcvs?rev=247964&root=gcc&view=rev
Log:
2017-05-12  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/67687
	* g++.dg/cpp0x/constexpr-ice17.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-ice17.C
Modified:
    trunk/gcc/testsuite/ChangeLog
Comment 6 Paolo Carlini 2017-05-12 11:26:03 UTC
Done.