[Bug tree-optimization/89672] NULL pointer check optimized out for the return value of memchr(NULL, c, 0)

2019-03-13 Thread him at revl dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89672

--- Comment #4 from Damon Revoe  ---
And that fact is used by the optimizer. I see. Thanks!

[Bug tree-optimization/89672] NULL pointer check optimized out for the return value of memchr(NULL, c, 0)

2019-03-13 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89672

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek  ---
C says e.g. for memchr:
"The memchr function locates the first occurrence of c (converted to an
unsigned
char) in the initial n characters (each interpreted as unsigned char) of the
object pointed to by s."
and elsewhere:
"If a null pointer constant is converted to a pointer type, the resulting
pointer, called a null pointer, is guaranteed to compare unequal to a pointer
to any object or function."
As memchr first argument must point to an object and NULL does not point to any
object, NULL is not a valid value.  It is similar to memcpy (NULL, NULL, 0) or
memset (NULL, 0, 0) etc. being invalid.

[Bug tree-optimization/89672] NULL pointer check optimized out for the return value of memchr(NULL, c, 0)

2019-03-13 Thread him at revl dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89672

--- Comment #2 from Damon Revoe  ---
Oops. Ironically, I checked the man page for whether NULL was a valid
argument. It just didn't occur to me to check the source. Duh.
Thank you for your time!

[Bug tree-optimization/89672] NULL pointer check optimized out for the return value of memchr(NULL, c, 0)

2019-03-12 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89672

Richard Biener  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #1 from Richard Biener  ---
I don't see that NULL is a valid first argument to memchr, in fact it is
declared with nonnull(1).