This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Patch to create builtin strncmp


On Wed, Mar 22, 2000 at 07:10:55PM -0500, Kaveh R. Ghazi wrote:
> Er, no you don't need to know the lengths of both strings.  You only
> need to know the length of *one* of them.  That's how the regular
> builtin strcmp works today.

Then expand_builtin_strcmp is wrong.  I don't see any wording
in md.texi that cmpstrsi must compare byte-wise and must not
read past the first mismatched byte.

Consider non-constant "hi\0" abutting a page boundary with
an unmapped page following.  Compare that with the constant
"hi there".  Recall that memcmp _is_ allowed to read N bytes,
and there's nothing to stop us reading 4 bytes from the first
string and faulting.

You may not even get a fault with the current compiler, but
that doesn't mean the code is correct.


r~

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]