bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: memmem issues


From: Paul Eggert
Subject: Re: memmem issues
Date: Mon, 31 Dec 2007 14:19:30 -0800
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

Bruno Haible <address@hidden> writes:

> It says that the _values_ of the characters are interpreted as
> unsigned char. I.e. like this:

Sure, but a character, as used in the sense here, is a bit
representation that fits in a byte (see section 3.7.1); it is not a
'char' value.  The intent is that memcmp looks at all the bits of the
underlying representation.  See, for example, footnote 43 of section
6.2.6.1:

   It is possible for objects x and y with the same effective type T
   to have the same value when they are accessed as objects of type T,
   but to have different values in other contexts. In particular, if
   == is defined for type T, then x == y does not imply that
   memcmp(&x, &y, sizeof (T)) == 0.  Furthermore, x == y does not
   necessarily imply that x and y have the same value; other
   operations on values of type T may distinguish between them.

Here again, the intent is that memcmp(&x, &y, sizeof (T)) compares all
the bits in the underlying representation.  The only way to do that
portably is via "unsigned char *".




reply via email to

[Prev in Thread] Current Thread [Next in Thread]