https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114541

            Bug ID: 114541
           Summary: Invalid gimple __BB# accepted due to usage of atoi
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid, ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
            Blocks: 44574, 101057
  Target Milestone: ---

Take:
```

/* { dg-do compile } */
/* { dg-options "-O -fgimple" } */

void __GIMPLE (ssa,startwith ("dse2")) foo ()
{
  int a;

__BB(2):
  if (a_5(D) > 4)
    goto __BB4294967299;
  else
    goto __BB4;

__BB(3):
  a_2 = 10;
  goto __BB5;

__BB(4):
  a_3 = 20;
  goto __BB5;

__BB(5):
  a_1 = __PHI (__BB3: a_2, __BB4: a_3);
  a_4 = a_1 + 4;

return;
}

```

This is invalid gimple but the use of atoi in c_parser_gimple_parse_bb_spec
(c/gimple-parser.cc) allows to accept it.

Note also causes ICE if you put any invalid character after the number due to
use of BB 1 at that point (I think).


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44574
[Bug 44574] Avoid use of atoi
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101057
[Bug 101057] [gimplefe] GIMPLE frontend issues

Reply via email to