Bug 59066 - [C++11] 'using' instead of 'typedef' causes a segmentation fault.
Summary: [C++11] 'using' instead of 'typedef' causes a segmentation fault.
Status: RESOLVED DUPLICATE of bug 60182
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2013-11-10 11:44 UTC by Alexandre Hamez
Modified: 2014-02-27 17:04 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.7.0, 4.8.0, 4.9.0
Last reconfirmed: 2014-02-14 00:00:00


Attachments
Preprocessed sources. (5.17 KB, text/plain)
2013-11-10 11:44 UTC, Alexandre Hamez
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexandre Hamez 2013-11-10 11:44:34 UTC
Created attachment 31188 [details]
Preprocessed sources.

G++ crashes with the following backtrace :

g++ -std=c++11  ./bug.ii -O0
./bug.ii: In member function 'SDD<C> homomorphism<C>::operator()(SDD<C>) [with C = conf0]':
./bug.ii:1203:60: internal compiler error: Segmentation fault
     return apply_binary_visitor(evaluation<C>(), **this, *x);

0x8a386f crash_signal
	../.././gcc/toplev.c:332
0xa37012 make_decl_rtl(tree_node*)
	../.././gcc/varasm.c:1197
0x64ac37 rtx_for_function_call
	../.././gcc/calls.c:1675
0x64ac37 expand_call(tree_node*, rtx_def*, int)
	../.././gcc/calls.c:2983
0x6f8f4b expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**)
	../.././gcc/expr.c:10246
0x655e20 expand_call_stmt
	../.././gcc/cfgexpand.c:2114
0x655e20 expand_gimple_stmt_1
	../.././gcc/cfgexpand.c:2152
0x655e20 expand_gimple_stmt
	../.././gcc/cfgexpand.c:2304
0x65668d expand_gimple_basic_block
	../.././gcc/cfgexpand.c:4138
0x6586e6 gimple_expand_cfg
	../.././gcc/cfgexpand.c:4657

G++ is called as follow:
g++ -std=c++11  ./bug.ii -O0
Comment 1 Alexandre Hamez 2013-11-10 12:03:37 UTC
I managed to reduce the code causing the segfault of gcc to ~1200 lines, but there are certainly still a lot of useless lines (coming from <type_traits>).
Comment 2 Alexandre Hamez 2013-11-10 13:22:03 UTC
I've found what causes the crash. On line 1199 of bug.ii, if 'using data_type = variant<identity<C>>' is changed to 'typedef variant<identity<C>> data_type', the segmentation no longer occurs [1].
I changed the summary to reflect that.

[1] Note that this particular code will fail to compile because of a missing member.
Comment 3 Paolo Carlini 2013-11-13 09:34:29 UTC
Doesn't look like a front-end issue.
Comment 4 Volker Reichelt 2014-02-14 21:16:07 UTC
Confirmed. Reduced testcase that crashes since GCC 4.7.0 when template
alias (aka 'using') was introduced:

============================================================================
template<typename T, template <typename> class U> void foo(const U<T>&) {}

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

void baz()
{
  foo(A<int>().bar());
}
============================================================================

Stack trace with current 4.8 branch:

bug.cc: In function 'void baz()':
bug.cc:11:22: internal compiler error: Segmentation fault
   foo(A<int>().bar());
                      ^
0xad469f crash_signal
        ../../gcc/gcc/toplev.c:332
0xcff5e2 tree_check
        ../../gcc/gcc/tree.h:3683
0xcff5e2 make_decl_rtl(tree_node*)
        ../../gcc/gcc/varasm.c:1197
0x7d72f3 rtx_for_function_call
        ../../gcc/gcc/calls.c:1675
0x7d72f3 expand_call(tree_node*, rtx_def*, int)
        ../../gcc/gcc/calls.c:2983
0x8aadcd expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**)
        ../../gcc/gcc/expr.c:10263
0x7e82fd expand_call_stmt
        ../../gcc/gcc/cfgexpand.c:2114
0x7e82fd expand_gimple_stmt_1
        ../../gcc/gcc/cfgexpand.c:2152
0x7e82fd expand_gimple_stmt
        ../../gcc/gcc/cfgexpand.c:2304
0x7e9162 expand_gimple_basic_block
        ../../gcc/gcc/cfgexpand.c:4138
0x7eacdc gimple_expand_cfg
        ../../gcc/gcc/cfgexpand.c:4657
Please submit a full bug report, [etc.]


Stack trace with trunk:

cc1plus: internal compiler error: Segmentation fault
0xba523f crash_signal
        ../../gcc/gcc/toplev.c:337
0x87e004 tree_check
        ../../gcc/gcc/tree.h:2918
0x87e004 decl_assembler_name_hash
        ../../gcc/gcc/symtab.c:98
0x87e46f insert_to_assembler_name_hash
        ../../gcc/gcc/symtab.c:209
0x87e5c1 symtab_initialize_asm_name_hash
        ../../gcc/gcc/symtab.c:432
0x88cda2 analyze_functions
        ../../gcc/gcc/cgraphunit.c:1124
0x88e2a5 finalize_compilation_unit()
        ../../gcc/gcc/cgraphunit.c:2320
0x689cae cp_write_global_declarations()
        ../../gcc/gcc/cp/decl2.c:4448
Please submit a full bug report, [etc.]
Comment 5 Volker Reichelt 2014-02-26 21:56:22 UTC
Jason, your patch for PR60182 seems to have fixed this one, too.
Do you want to add the reduced testcase (in comment#4) to the testsuite?
Comment 6 Jason Merrill 2014-02-27 17:04:11 UTC
I don't think the testcase is sufficiently different.  Thanks.

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