Date: Sun, 23 Sep 2007 15:35:52 +0200 From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no> To: Bruce Evans <brde@optusnet.com.au> Cc: cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org, Sean Farley <scf@FreeBSD.org> Subject: Re: cvs commit: src/lib/libc/stdlib getenv.c Message-ID: <86wsuhv70n.fsf@ds4.des.no> In-Reply-To: <20070922202914.B90809@besplex.bde.org> (Bruce Evans's message of "Sat\, 22 Sep 2007 21\:20\:48 %2B1000 \(EST\)") References: <200709220230.l8M2UiRK020609@repoman.freebsd.org> <86r6krqbrd.fsf@ds4.des.no> <20070922202914.B90809@besplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Bruce Evans <brde@optusnet.com.au> writes: > On Sat, 22 Sep 2007, [utf-8] Dag-Erling Sm=C3=B8rgrav wrote: > > s/to remove the warning/to actually work/ > Please be precise :-). > s/to remove the warning ... on 64-bit platforms/to avoid undefined behavi= our > 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: > - size_t is always an unsigned type, but the required type is int, so > size_t is never compatible with the required type. > - on platforms where size_t is smaller than int, the arg type is > nevertheless compatible with int, since warnx() is variadic and the > arg is one of the variadic args; the default promotions thus apply > and the arg is passed as an int whether or not you cast it explicitly > to int (but casting it to a type larger than int would break it). > FreeBSD doesn't support any platforms in this class. > - on platforms where size_t is u_int, the arg is passed as a u_int. > The analysis for this case is too delicate to give in full here. 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. DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86wsuhv70n.fsf>