Bug 111816 - [gimple FE] ICE with _GIMPLE(ssa) and 2 returns
Summary: [gimple FE] ICE with _GIMPLE(ssa) and 2 returns
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 14.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks: gimplefe
  Show dependency treegraph
 
Reported: 2023-10-15 01:21 UTC by wierton
Modified: 2023-11-04 19:20 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2023-11-04 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description wierton 2023-10-15 01:21:47 UTC
When compile this program with GCC-14, GCC crashes:
```
__GIMPLE (ssa) int foo (int *a)
{
  return 0;
  return 0;
}
```

Compiler Explorer: https://godbolt.org/z/zecdo68WE

The full stack dump:
```
<source>: In function 'foo':
<source>:5:1: internal compiler error: Segmentation fault
    5 | }
      | ^
0x22ff3ee internal_error(char const*, ...)
	???:0
0xaad8ac c_parser_parse_gimple_body(c_parser*, char*, c_declspec_il, profile_count)
	???:0
0xaa468d c_parse_file()
	???:0
0xb17919 c_common_parse_file()
	???:0
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
```
Comment 1 Andrew Pinski 2023-10-15 01:26:30 UTC
Note even though the gimple FE exists, it is mainly designed ONLY for testsuite usage and that there will be many corner cases like this where code will cause an ICE rather than be rejected for being invalid.
Comment 2 Richard Biener 2023-10-16 06:53:35 UTC
Speicfically we're not interested in "fuzzing" it, but only cases you run into when you are trying to exercise it for its purpose.
Comment 3 Andrew Pinski 2023-11-04 19:20:15 UTC
Confirmed.

      /* We have a CFG.  Build the edges.  */
      for (unsigned i = 0; i < parser.edges.length (); ++i)
        {
          edge e = make_edge (BASIC_BLOCK_FOR_FN (cfun, parser.edges[i].src),
                              BASIC_BLOCK_FOR_FN (cfun, parser.edges[i].dest),
                              parser.edges[i].flags);
          e->probability = parser.edges[i].probability;
        }



make_edge is returning NULL.