cvs commit: src/lib/libc/stdlib getenv.c

Bruce Evans brde at optusnet.com.au
Sun Sep 23 09:19:43 PDT 2007


On Sun, 23 Sep 2007, [utf-8] Dag-Erling Smørgrav wrote:

> Bruce Evans <brde at optusnet.com.au> writes:
>> On Sat, 22 Sep 2007, [utf-8] Dag-Erling Smørgrav wrote:
>>> s/to remove the warning/to actually work/
>> Please be precise :-).
>> s/to remove the warning ... on 64-bit platforms/to avoid undefined behaviour
>> on platforms where size_t is not u_int, and to avoid having to make a
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> delicate analysis to show that the behaviour is defined and correct on
>> all other platforms/.
>>
>> Delicate analysis:
>> ...

> you left out the case where size_t is larger than unsigned int, i.e. all
> 64-bit platforms.  Even if the stack is aligned to the size of size_t,
> you will get interesting results on a big-endian system.

Nope.  This is a trivial subcase of a case that I didn't leave out.
Platforms where size_t is not u_int includes all platforms where size_t
is larger than u_int spelled verbosely.  This is not all 64-bit
platforms, but some 64-bit platforms including all 64-bit platforms
supported by FreeBSD.

I think stack alignment gives uninteresting results in practice even
on big-endian systems, since the least significant bytes normally end
up in the place where a type pun will see them by going through a
register.  This is most obvious if they are passed in a register, which
can happen even for variadic args -- then endianness has no significant
effect.  I think lots of code still depends on the alignment to make
things sort of work.

Bruce


More information about the cvs-all mailing list