https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122502
--- Comment #14 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Sergei Trofimovich from comment #13)
> Another example seemingly not fixed by this change from `ffmpeg-8.0`:
>
> // $ cat softfloat.c.c
> typedef struct {
> int mant;
> int exp
> } SoftFloat;
> SoftFloat __trans_tmp_8, main___trans_tmp_5;
> static SoftFloat av_normalize_sf(SoftFloat a) {
> while (a.mant + 536870911 < 1073741823) {
> a.mant += a.mant;
> a.exp -= 1;
> }
> return a;
> }
> void main() {
> main___trans_tmp_5 = av_normalize_sf((SoftFloat){1, 29 + 1});
> SoftFloat sf1 = main___trans_tmp_5;
> for (;;) {
> int t = main___trans_tmp_5.exp - sf1.exp;
> if (t < 2)
> sf1 = __trans_tmp_8;
> }
> }
>
> gcc/xgcc -Bgcc -c softfloat.c.c -O2
> softfloat.c.c:4:1: warning: no semicolon at end of struct or union
> 4 | } SoftFloat;
> | ^
> during GIMPLE pass: sccp
> softfloat.c.c: In function ‘main’:
> softfloat.c.c:13:6: internal compiler error: Segmentation fault
> 13 | void main() {
> | ^~~~
> 0x26506c4 diagnostics::context::diagnostic_impl(rich_location*,
> diagnostics::metadata const*, diagnostics::option_id, char const*,
> __va_list_tag (*) [1], diagnostics::kind)
This is the similar issue but in a different location. This time it is back in
replace_uses_by which does:
```
FOR_EACH_IMM_USE_STMT (stmt, imm_iter, name)
{
/* Mark the block if we change the last stmt in it. */
if (cfgcleanup_altered_bbs
&& stmt_ends_bb_p (stmt))
bitmap_set_bit (cfgcleanup_altered_bbs, gimple_bb (stmt)->index);
FOR_EACH_IMM_USE_ON_STMT (use, imm_iter)
{
...
if (fold_stmt (&gsi))
stmt = gsi_stmt (gsi);
...
```
I remember running into this exact same thing before; I remember doing the
folding after the FOR_EACH loop in replace_uses_by but I can't remember what I
did to hit it nor why I decided I was doing something else wrong.