Bug 84745 - internal compiler error: Segmentation fault (main_block_label())
Summary: internal compiler error: Segmentation fault (main_block_label())
Status: RESOLVED DUPLICATE of bug 772
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.0.1
: P4 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2018-03-07 07:21 UTC by Vegard Nossum
Modified: 2021-07-22 23:16 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-03-07 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-07 07:21:51 UTC
Input:

void a() {
  alignof(({
    b: 0;
  }));
  goto b;
}

Output:

$ xgcc -x c++ -S -
during GIMPLE pass: cfg
<stdin>: In function 'void a()':
<stdin>:1:6: internal compiler error: Segmentation fault
0x3152ce9 crash_signal
        /home/vegard/git/gcc/gcc/toplev.c:325
0x32834db main_block_label
        /home/vegard/git/gcc/gcc/tree-cfg.c:1496
0x3292fff cleanup_dead_labels()
        /home/vegard/git/gcc/gcc/tree-cfg.c:1679
0x32f0b70 build_gimple_cfg
        /home/vegard/git/gcc/gcc/tree-cfg.c:240
0x32f0b70 execute_build_cfg
        /home/vegard/git/gcc/gcc/tree-cfg.c:410
0x32f0b70 execute
        /home/vegard/git/gcc/gcc/tree-cfg.c:446

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

Built from git 11a93d7a09b871b3b9a2eb108eb91ad83d94e070 (r258271).

Funnily, clang also segfaults on this exact input.

Test case was minimised by C-Reduce.
Comment 1 David Malcolm 2018-03-07 18:10:56 UTC
Confirmed with trunk, gcc7 and gcc 6, and all the way back to at least 4.8.3 (using -std=c++11).
 
Program received signal SIGSEGV, Segmentation fault.
main_block_label (label=label@entry=0x7ffff18d5100) at ../../src/gcc/tree-cfg.c:1496
1496	  tree main_label = label_for_bb[bb->index].label;

(gdb) p bb
$1 = <basic_block 0x0>
Comment 2 Andrew Pinski 2021-07-22 23:16:00 UTC
jumping into statement expressions should be invalid, and is correctly rejected for the C front-end.
This is a dup of PR 772.

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