Bug 81024 - ICE within convert_like_real with std::initializer_list
Summary: ICE within convert_like_real with std::initializer_list
Status: RESOLVED DUPLICATE of bug 80956
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-08 16:02 UTC by David Malcolm
Modified: 2018-05-08 09:11 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-10-19 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Malcolm 2017-06-08 16:02:04 UTC
Found by Alec Teal; reported to me over IRC.

Seen with gcc 4.8 and with trunk (r248825).

$ cat main.cc
namespace std { 
template<class T> class initializer_list;
}
void WtfTest(int, const char*, const char*, const ::std::initializer_list<const char*>&);
#define WTF(...) WtfTest(__LINE__,__FILE__,"potato",{__VA_ARGS__});
int main() { WTF("it","works") }

gcc main.cc
main.cc: In function ‘int main()’:
main.cc:5:66: internal compiler error: Segmentation fault
 #define WTF(...) WtfTest(__LINE__,__FILE__,"potato",{__VA_ARGS__});
                                                                  ^
main.cc:6:14: note: in expansion of macro ‘WTF’
 int main() { WTF("it","works") }
              ^~~
0xb7f806 crash_signal
	../../src/gcc/toplev.c:338
0x60797d convert_like_real
	../../src/gcc/cp/call.c:6805
0x6076bc convert_like_real
	../../src/gcc/cp/call.c:6838
0x60a4cd build_over_call
	../../src/gcc/cp/call.c:7840
0x61250e build_new_function_call(tree_node*, vec<tree_node*, va_gc, vl_embed>**, int)
	../../src/gcc/cp/call.c:4262
0x727d25 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool, bool, int)
	../../src/gcc/cp/semantics.c:2479
0x6c990d cp_parser_postfix_expression
	../../src/gcc/cp/parser.c:6998
0x6d0446 cp_parser_unary_expression
	../../src/gcc/cp/parser.c:8117
0x6d0f65 cp_parser_cast_expression
	../../src/gcc/cp/parser.c:8796
0x6d1562 cp_parser_binary_expression
	../../src/gcc/cp/parser.c:8898
0x6d1cb2 cp_parser_assignment_expression
	../../src/gcc/cp/parser.c:9186
0x6d923a cp_parser_expression
	../../src/gcc/cp/parser.c:9353
0x6da32a cp_parser_expression_statement
	../../src/gcc/cp/parser.c:10912
0x6c5376 cp_parser_statement
	../../src/gcc/cp/parser.c:10728
0x6c6377 cp_parser_statement_seq_opt
	../../src/gcc/cp/parser.c:11054
0x6c642f cp_parser_compound_statement
	../../src/gcc/cp/parser.c:11008
0x6e1330 cp_parser_function_body
	../../src/gcc/cp/parser.c:21447
0x6e1330 cp_parser_ctor_initializer_opt_and_function_body
	../../src/gcc/cp/parser.c:21483
0x6e1b2e cp_parser_function_definition_after_declarator
	../../src/gcc/cp/parser.c:26291
0x6e2a9c cp_parser_function_definition_from_specifiers_and_declarator
	../../src/gcc/cp/parser.c:26203
Comment 1 David Malcolm 2017-06-08 16:08:39 UTC
Segfault is a read through NULL in convert_like_real at line 6805 here,
within the handling for:

  /* Conversion to std::initializer_list<T>.  */

  (gdb) list
  6800	
  6801		/* Build up the initializer_list object.  */
  6802		totype = complete_type (totype);
  6803		field = next_initializable_field (TYPE_FIELDS (totype));
  6804		CONSTRUCTOR_APPEND_ELT (vec, field, array);
>>6805		field = next_initializable_field (DECL_CHAIN (field));
  6806		CONSTRUCTOR_APPEND_ELT (vec, field, size_int (len));
  6807		new_ctor = build_constructor (totype, vec);
  6808		return get_target_expr_sfinae (new_ctor, complain);
  6809	      }

  (gdb) p field
  $1 = <tree 0x0>
Comment 2 Paolo Carlini 2018-05-08 09:11:23 UTC
Dup.

*** This bug has been marked as a duplicate of bug 80956 ***