c/10339: strncmp generates imPure code
Falk Hueffner
falk.hueffner@student.uni-tuebingen.de
Mon Apr 7 19:36:00 GMT 2003
The following reply was made to PR optimization/10339; it has been noted by GNATS.
From: Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
To: Michael Ubell <ubell@mindspring.com>
Cc: Wolfgang Bangerth <bangerth@ices.utexas.edu>, gcc-bugs@gcc.gnu.org,
gcc-gnats@gcc.gnu.org
Subject: Re: c/10339: strncmp generates imPure code
Date: 07 Apr 2003 21:27:02 +0200
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-prs
mailing list