This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: large integer implicitly truncated to unsigned type
- To: Keith Owens <kaos at ocs dot com dot au>
- Subject: Re: large integer implicitly truncated to unsigned type
- From: Geoff Keating <geoffk at cygnus dot com>
- Date: 23 Oct 2000 01:14:49 -0700
- CC: gcc-bugs at gcc dot gnu dot org
- References: <4384.972284274@kao2.melbourne.sgi.com>
Keith Owens <kaos@ocs.com.au> writes:
> CVS gcc October 22, 2000 gives lots of
>
> warning: large integer implicitly truncated to unsigned type
>
> messages for constructs like this.
>
> #define CMSG_ALIGN(len) ( ((len)+sizeof(long)-1) & ~(sizeof(long)-1) )
>
> Changing to
>
> #define CMSG_ALIGN(len) ( ((len)+sizeof(long)-1) & (unsigned)~(sizeof(long)-1) )
>
> removes the warning. Is this warning message correct and is it going
> to be a permanent feature of gcc? If so I will do a kernel patch to
> make (unsigned) explicit.
No, it's a bug. 'sizeof(long)' is already of type size_t, which is
either 'unsigned int' or 'unsigned long' on most systems,
and on those systems the type of (sizeof(long)-1) is therefore also
size_t by the arithmetic conversion rules.
--
- Geoffrey Keating <geoffk@cygnus.com>