https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107010
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=77964 Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- That is because GCC knows that first+1 does not point to a valid pointer really. You need to hide the assignment of iterator from GCC. This will fix the issue: const struct linkinfostruct *iterator = &first; asm("":"+r"(iterator)); while (iterator->name) { fprintf (stderr, "name=%s\n", iterator->name); iterator++; fprintf (stderr, " next iteration should be (iterator=%p, &iterator->name=%p name=%p \"%s\"\n", iterator, &iterator->name, iterator->name, iterator->name); } See PR 77964 and PR 106939 also.