Possible problem with inline string functions in glibc, sysdeps/i386/i486/bits/string.h

Jakub Jelinek jakub@redhat.com
Thu Jan 2 13:17:00 GMT 2003


On Fri, Jan 03, 2003 at 12:15:01AM +1100, Davin McCall wrote:
> Hi,
> 
> I'm a bit worried that the dummy ouput operands for a couple
> of the implemented-as-asm functions in sysdeps/i386/i486/bits/string.h 
> aren't really correct.
> 
> Specifically the "mem*()" class of functions take "void *" arguments and
> therefore I assume that in fact any type of pointer (say an "int *" or
> some sort of struct ptr) could be passed to these functions.
> However, a character array is used as the dummy output operand for these
> functions.
> 
> Due to aliasing considerations it seems to me that it might then
> be possible for the compiler to assume that (in the case where the type
> of the argument is not actually char *) the buffer contents have not
> changed across the function call. Therefore it might cache values
> from the buffer in registers and use those same values after the
> function call when the buffer is accessed, even though the
> buffer has really been modified.

See ISO C99, 6.5 (7):
An object shall have its stored value accessed only by an lvalue
expression that has one of the following types:
-- a type compatible with the effective type of the object,
...
-- a character type.

	Jakub



More information about the Libc-alpha mailing list