NetBSD-Users archive

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

Re: toupper and warnings



On Thu, May 06, 2021 at 12:52:36PM -0700, Greg A. Woods wrote:
>[...] 
> Well I don't actually do that.
> 
> Which is to say my implementation's goal is to turn them into properly
> promoted values and access the flags array in such a way that this does
> not and cannot "cause" UB.  My implementation carefully tests for a -1
> and then if it is not -1 it uses a cast and assignment to an unsigned
> char, the value of which is then used to access the array.  I.e. totally
> safe _and_ UB-free.
> 

I guess you mean testing not against -1 but testing against EOF? Because
strictly speaking, EOF could be whatever integer value not in the
unsigned char range (and this is why too casting to unsigned char is
necessary because -1 is in the range of a signed char; after all, not
considering EOF for other usages, in this case EOF could be an
impossible signed or unsigned char value).
-- 
        Thierry Laronde <tlaronde +AT+ polynum +dot+ com>
                     http://www.kergis.com/
                    http://kertex.kergis.com/
                       http://www.sbfa.fr/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C


Home | Main Index | Thread Index | Old Index