This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/85725] strchr and strstr of a one-element array with a non-empty string can be assumed to return null
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 11 May 2018 13:52:58 +0000
- Subject: [Bug tree-optimization/85725] strchr and strstr of a one-element array with a non-empty string can be assumed to return null
- Auto-submitted: auto-generated
- References: <bug-85725-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85725
--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
That's right: unless otherwise specified, string functions require as arguments
valid strings, or as the C++ standard defines them, NTBS (nul-terminated byte
string). Thus the only valid string that can be stored in char[1] is the empty
string. The memchr function must be used to find the first occurrence of a
character in an arbitrary (not necesarily nul-terminated) sequence of bytes.