[prev in list] [next in list] [prev in thread] [next in thread]
List: gmp-bugs
Subject: Type of USHRT_MAX
From: tg () gmplib ! org (Torbjorn Granlund)
Date: 2013-06-10 11:28:26
Message-ID: 86vc5m19yd.fsf () shell ! gmplib ! org
[Download RAW message or body]
Marc Glisse <marc.glisse at inria.fr> writes:
according to the C standard, USHRT_MAX has type int (or unsigned int
if short and int have the same size). __GMP_USHRT_MAX has type
unsigned short. GMP sometimes defines USHRT_MAX as __GMP_USHRT_MAX,
and always assumes that USHRT_MAX has type unsigned short (in printf
in particular). This seems to only affect the testsuite, but it would
still be nice to fix (some compilers give warnings).
I suppose we should not deviate from the standard.
Should __GMP_USHRT_MAX be defined to ((unsigned
int)current_definition) and the 'h' in printf format strings removed,
or should USHRT_MAX be cast to (unsigned short) where needed? Or
something else?
I think 'short' arguments to stdarg functions like printf will be
promoted to int.
The h printf modifier then only has the effect of truncating the int
argument to the range of 'short'. (Using h will only ever invoke
undefined behaviour, unless followed by o,u,x,or X...)
--
Torbj?rn
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic