https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122462
--- Comment #2 from Jiang XueZhi <jiangxuezhi2 at huawei dot com> ---
(In reply to Richard Biener from comment #1)
> I think this needs -fno-delete-null-pointer-checks as well to reliably
> suppress optimization.
Thanks for the reminder, it should add option -fno-delete-null-pointer-checks
But, the result is same as before:
gcc -fno-delete-null-pointer-checks -O3 -Wall test.c -o test
gcc -fno-delete-null-pointer-checks -fwrapv-pointer -O3 -Wall test.c -o test
the output of these commands are same:
<source>: In function 'kkk':
<source>:4:25: warning: the comparison will always evaluate as 'false' for the
pointer operand in 'pNext + 1' must not be NULL [-Waddress]
4 | return !!(pNext + 1 == (void *)0);
| ^~
So, I'm currently confused: if -fwrapv-pointer actually changes the generated
assembly, wouldn't it be more reasonable for it to also affect the compiler's
output (e.g., warnings)?