https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71966
Bug ID: 71966
Summary: ICE on invalid C++11 code (undefined constructor used
in a constant expression): in cp_build_addr_expr_1, at
cp/typeck.c:5671
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: su at cs dot ucdavis.edu
Target Milestone: ---
The following C++11 code causes an ICE when compiled with the current GCC trunk
on x86_64-linux-gnu in both 32-bit and 64-bit modes.
This is a regression from 6.1.x.
$ g++-trunk -v
Using built-in specs.
COLLECT_GCC=g++-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto
--prefix=/usr/local/gcc-trunk --disable-bootstrap
Thread model: posix
gcc version 7.0.0 20160722 (experimental) [trunk revision 238631] (GCC)
$
$ g++-6.1 -c small.cpp
small.cpp:9:17: error: ‘constexpr A::A(int)’ used before its definition
constexpr A a = 0;
^
small.cpp:3:13: warning: inline function ‘constexpr A::A(int)’ used but never
defined
constexpr A (int); // should be e.g.: constexpr A (int) {};
^
$
$ g++-trunk -c small.cpp
small.cpp:9:17: error: ‘constexpr A::A(int)’ used before its definition
constexpr A a = 0;
^
small.cpp:10:7: internal compiler error: in cp_build_addr_expr_1, at
cp/typeck.c:5671
B < a > b;
^
0x7ab358 cp_build_addr_expr_1
../../gcc-source-trunk/gcc/cp/typeck.c:5671
0x64d772 add_function_candidate
../../gcc-source-trunk/gcc/cp/call.c:2108
0x64eef7 add_candidates
../../gcc-source-trunk/gcc/cp/call.c:5382
0x64a2bc build_user_type_conversion_1
../../gcc-source-trunk/gcc/cp/call.c:3754
0x64b26a implicit_conversion
../../gcc-source-trunk/gcc/cp/call.c:1866
0x65327d build_integral_nontype_arg_conv(tree_node*, tree_node*, int)
../../gcc-source-trunk/gcc/cp/call.c:3937
0x6c3b9d convert_nontype_argument
../../gcc-source-trunk/gcc/cp/pt.c:6389
0x6caa23 convert_template_argument
../../gcc-source-trunk/gcc/cp/pt.c:7284
0x6d604b coerce_template_parms
../../gcc-source-trunk/gcc/cp/pt.c:7745
0x6d8d7a lookup_template_class_1
../../gcc-source-trunk/gcc/cp/pt.c:8318
0x6d8d7a lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
../../gcc-source-trunk/gcc/cp/pt.c:8659
0x7f535d finish_template_type(tree_node*, tree_node*, int)
../../gcc-source-trunk/gcc/cp/semantics.c:3133
0x7816f4 cp_parser_template_id
../../gcc-source-trunk/gcc/cp/parser.c:14961
0x78199a cp_parser_class_name
../../gcc-source-trunk/gcc/cp/parser.c:21265
0x7703bd cp_parser_qualifying_entity
../../gcc-source-trunk/gcc/cp/parser.c:6271
0x7703bd cp_parser_nested_name_specifier_opt
../../gcc-source-trunk/gcc/cp/parser.c:5955
0x782117 cp_parser_constructor_declarator_p
../../gcc-source-trunk/gcc/cp/parser.c:25190
0x782117 cp_parser_decl_specifier_seq
../../gcc-source-trunk/gcc/cp/parser.c:12787
0x78b691 cp_parser_simple_declaration
../../gcc-source-trunk/gcc/cp/parser.c:12336
0x78bb11 cp_parser_block_declaration
../../gcc-source-trunk/gcc/cp/parser.c:12283
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.
$
---------------------------------------------------------------
struct A
{
constexpr A (int); // should be e.g.: constexpr A (int) {};
constexpr operator int () const { return 0; }
};
template < int > struct B {};
constexpr A a = 0;
B < a > b;