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] Builtin strcpy/strncpy/memcpy/strcmp/fputs fixes and optimizations


On Thu, Nov 30, 2000 at 08:59:35AM -0500, Kaveh R. Ghazi wrote:
>  > From: Jakub Jelinek <jakub@redhat.com>
>  > 
>  > fputs ("foobar" + (i++ & 3), f) and miscompile
>  > 
>  > To sum up, c_getstr guarantees the argument is constant string with constant
>  > length without side effects if returning non-NULL, while c_strlen does not
>  > (I think it just guarantees that if it returns an INTEGER_CST that it does
>  > not have side effects).
> 
> I want to make sure I understand this.  The c_strlen() function won't
> return an INTEGER_CST for the fputs() case above but *will* return a
> non-NULL tree expr which corresponds to "6 - (i++ & 3)", right?

Exactly.

> That's why you have to check whether its an INTEGER_CST or prefer
> c_getstr?

c_getstr will return NULL in that case, because the string is not computable
at compile time.

	Jakub

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