http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60708

            Bug ID: 60708
           Summary: An array temporary causes an ICE in gimplify
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ville.voutilainen at gmail dot com

Test:

template <class T, class U> struct mypair {
  mypair(T, U) {}
};

template <class T, class U> auto my_make_pair(T t, U u)
{
  return mypair<T, U>(t, u);
}

template<typename T> struct S {
 mypair<T *, int> get_pair() noexcept { 
   return my_make_pair((T*)nullptr, 0); 
 } 
}; 

static void foo(const mypair<char *, int> (&a)[2]) noexcept { } 

int main()
{ 
  S<char> s; 
  //mypair<char*, int> jones[2]{s.get_pair(), s.get_pair()};
  //foo(jones);
  foo({s.get_pair(), s.get_pair()}); 
}

If the commented lines are present, this compiles fine. I don't know why,
because with the code as written, the following explosion happens:

lhcat2.cpp: In function ‘int main()’:
lhcat2.cpp:24:35: internal compiler error: Segmentation fault
   foo({s.get_pair(), s.get_pair()}); 
                                   ^
0xb50aff crash_signal
    ../../gcc/toplev.c:337
0x9b590d gimplify_target_expr
    ../../gcc/gimplify.c:5255
0x9a2d2c gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
    ../../gcc/gimplify.c:7815
0x9ac27d gimplify_addr_expr
    ../../gcc/gimplify.c:4801
0x9a2935 gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
    ../../gcc/gimplify.c:7494
0x9acdb8 gimplify_call_expr
    ../../gcc/gimplify.c:2375
0x9a24c7 gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
    ../../gcc/gimplify.c:7419
0x9a6e16 gimplify_stmt(tree_node**, gimple_statement_base**)
    ../../gcc/gimplify.c:5341
0x9a2552 gimplify_cleanup_point_expr
    ../../gcc/gimplify.c:5117
0x9a2552 gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
    ../../gcc/gimplify.c:7811
0x9a6e16 gimplify_stmt(tree_node**, gimple_statement_base**)
    ../../gcc/gimplify.c:5341
0x9a2fdb gimplify_statement_list
    ../../gcc/gimplify.c:1412
0x9a2fdb gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
    ../../gcc/gimplify.c:7863
0x9a6e16 gimplify_stmt(tree_node**, gimple_statement_base**)
    ../../gcc/gimplify.c:5341
0x9a7b1f gimplify_bind_expr
    ../../gcc/gimplify.c:1079
0x9a2a0e gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
    ../../gcc/gimplify.c:7645
0x9a6e16 gimplify_stmt(tree_node**, gimple_statement_base**)
    ../../gcc/gimplify.c:5341
0x9a2fdb gimplify_statement_list
    ../../gcc/gimplify.c:1412
0x9a2fdb gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
    ../../gcc/gimplify.c:7863
0x9a6e16 gimplify_stmt(tree_node**, gimple_statement_base**)
    ../../gcc/gimplify.c:5341
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.

Reply via email to