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

            Bug ID: 108398
           Summary: tree-object-size trips up with pointer arithmetic if
                    an intermediate result is an invalid pointer
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: siddhesh at gcc dot gnu.org
  Target Milestone: ---

Reproducer:

unsigned steps[2];

int main(void) {
    for (unsigned *io = steps; 0 < sizeof (steps) / sizeof (unsigned); io++) {
        if (*io == 0) {
            if (__builtin_dynamic_object_size (io, 0) != sizeof (unsigned))
                __builtin_abort ();
            io--;
        }
    }

    return 0;
}

$ gcc -O1 prima.c -o prima
$ ./prima
Aborted (core dumped)

io may momentarily point before steps, which is what seems to trip up
tree-object-size.

Reply via email to