https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105585
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|NEW |RESOLVED
--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
The warning is caused by the if statement: if p is null, accessing the p->a
member is undefined. It triggers because the GCC optimizer splits the code
into two branches: one with a nonnull p and another with a null p. The second
one triggers the warning.
If p can be null then moving the increment to the body of the if statement
avoids the undefined behavior (and the warning). If p cannot be null then
making the if statement unconditional also avoids the warning.