c/10339: strncmp generates imPure code
Falk Hueffner
falk.hueffner@student.uni-tuebingen.de
Mon Apr 7 19:27:00 GMT 2003
Michael Ubell <ubell@mindspring.com> writes:
> > I suspect the extra byte read is actually not relevant for the result,
> > and because of alignment, gcc knows the second problem cannot occur,
> > but I have neither a SPARC nor SPARC knowledge to test that.
>
> Actually if you make the compare string longer you can get it to
> look at an arbitrary number of bytes passed the allocated part, so I
> think this could fault if you set it up right. Also in the original
> problem, the first argument was not allocated locally so the
> compiler would have no idea how big or what its alignment was. (In
> fact it was in a loop comparing strings from an array.)
Could you perhaps provide such an example? For your original example,
gcc knows that malloc returns only aligned pointers.
--
Falk
More information about the Gcc-bugs
mailing list