Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 17 Apr 2015 22:34:17 +0200
From: Jens Gustedt <jens.gustedt@...ia.fr>
To: musl@...ts.openwall.com
Subject: Re: Explicit casts in ctype.h suppress compiler warnings

Am Freitag, den 17.04.2015, 20:35 +0200 schrieb Szabolcs Nagy:
> #define isdigit(a) (((0?1U:(a))-'0') < 10)
> 
> which works when the conversion rank of a is <= unsigned

but not if it has conversion rank larger then unsigned and the result
of the substraction has a negative result. So what you think of

#define isdigit(a) (((0?1ULL:(a))-'0') < 10ULL)

This ensures that the type of the left is always ullong, so the
substraction overflows to something big if a is not a digit.

Jens


-- 
:: INRIA Nancy Grand Est ::: Camus ::::::: ICube/ICPS :::
:: ::::::::::::::: office Strasbourg : +33 368854536   ::
:: :::::::::::::::::::::: gsm France : +33 651400183   ::
:: ::::::::::::::: gsm international : +49 15737185122 ::
:: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::




Download attachment "signature.asc" of type "application/pgp-signature" (182 bytes)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.