https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93156
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note the best way to implement null_ptr really (without the need for the
attribute is the following):
/* Return NULL.
Usual compilers are not able to infer something about the return value. */
static void *
null_ptr (void)
{
typedef void *voidptr;
volatile voidptr n = 0;
return n;
}
NOTE also:
unsigned int y = x * x;
if (y & 2)
Is always false even for overflow case so even then it will return null always
and if it gets inlined, then GCC is not assuming anything about the return
value.