Bug 84714 - internal compiler error: in create_tmp_var, at gimple-expr.c:476
Summary: internal compiler error: in create_tmp_var, at gimple-expr.c:476
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.0.1
: P3 normal
Target Milestone: 10.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2018-03-05 13:23 UTC by Vegard Nossum
Modified: 2021-07-22 23:26 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-03-05 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vegard Nossum 2018-03-05 13:23:10 UTC
Input:

void a(struct b &c) {
  asm ("" : "+r" (c));
}

Output:

$ xgcc -x c++ -S -
<stdin>: In function 'void a(b&)':
<stdin>:2:19: internal compiler error: in create_tmp_var, at gimple-expr.c:476
0x20f1583 create_tmp_var(tree_node*, char const*)
        /home/vegard/git/gcc/gcc/gimple-expr.c:476
0x2218dd6 create_tmp_from_val
        /home/vegard/git/gcc/gcc/gimplify.c:516
0x2218dd6 lookup_tmp_var
        /home/vegard/git/gcc/gcc/gimplify.c:537
0x2218dd6 internal_get_tmp_var
        /home/vegard/git/gcc/gcc/gimplify.c:590
0x221b55c get_formal_tmp_var(tree_node*, gimple**)
        /home/vegard/git/gcc/gcc/gimplify.c:618
0x221b55c gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int)
        /home/vegard/git/gcc/gcc/gimplify.c:12383
0x22469bd gimplify_asm_expr
        /home/vegard/git/gcc/gcc/gimplify.c:6328
0x221cc11 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int)
        /home/vegard/git/gcc/gcc/gimplify.c:11766
0x222b991 gimplify_stmt(tree_node**, gimple**)
        /home/vegard/git/gcc/gcc/gimplify.c:6658
0x221da9d gimplify_cleanup_point_expr
        /home/vegard/git/gcc/gcc/gimplify.c:6400
0x221da9d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int)
        /home/vegard/git/gcc/gcc/gimplify.c:11811
0x222b991 gimplify_stmt(tree_node**, gimple**)
        /home/vegard/git/gcc/gcc/gimplify.c:6658
0x2234c59 gimplify_body(tree_node*, bool)
        /home/vegard/git/gcc/gcc/gimplify.c:12635
0x2236fb0 gimplify_function_tree(tree_node*)
        /home/vegard/git/gcc/gcc/gimplify.c:12800
0x19a3517 cgraph_node::analyze()
        /home/vegard/git/gcc/gcc/cgraphunit.c:670
0x19b65eb analyze_functions
        /home/vegard/git/gcc/gcc/cgraphunit.c:1131
0x19bb301 symbol_table::finalize_compilation_unit()
        /home/vegard/git/gcc/gcc/cgraphunit.c:2691

$ xgcc --version
xgcc (GCC) 8.0.1 20180303 (experimental)

Built from git 0d86c284d085d29782d862600a79aa1ff0ee0c47 (r258221).

4.1.2 gives the same thing.

Clang gives:

input.cc:2:19: error: dereference of pointer to incomplete type 'struct b'
  asm ("" : "+r" (c));
                  ^
input.cc:1:15: note: forward declaration of 'b'
void a(struct b &c) {
              ^
1 error generated.

Test case was minimised by C-Reduce.
Comment 1 David Malcolm 2018-03-05 15:22:42 UTC
Assertion failure here:

#1  0x0000000000cc4a0b in create_tmp_var (type=type@entry=<record_type 0x7ffff1a079d8 b>, prefix=<optimized out>)
    at ../../src/gcc/gimple-expr.c:476
476	  gcc_assert (!TREE_ADDRESSABLE (type) && COMPLETE_TYPE_P (type));
Comment 2 Andrew Pinski 2021-07-22 23:26:12 UTC
Fixed in GCC 10.