This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: long long int array warning
- To: ehallick at edam dot cpm dot com (Erick Hallick)
- Subject: Re: long long int array warning
- From: Geoff Keating <geoffk at cygnus dot com>
- Date: 13 Jun 2000 11:20:07 -0700
- CC: gcc-bugs at gcc dot gnu dot org
- References: <01BFD51C.C7166F00@madisondhcp-152.cpm.com>
ehallick@mail.cpm.com (Erick Hallick) writes:
> Hello,
>
> I am getting a strange warning which I believe is incorrect when declaring
> an array of long long int's. Consider the following simple code:
>
> #include <stdio.h>
>
> int main()
> {
> int i;
> long long int a[] =
> {
> 1,
> 2,
> 2000000000,
> 4000000000,
> 8000000000,
> -8000000000
> };
>
> for(i=0;i<=5;i++)
> printf("a[%d] = %lld\n", i, a[i]);
>
>
> return 0;
> }
>
> I get the following error while compiling:
>
> ehallick@netfinity:~ > gcc -Wall test.c
> test.c: In function `main':
> test.c:11: warning: decimal constant is so large that it is unsigned
This is warning you that the constant 4000000000 is being treated as
an 'unsigned int', rather than the 'int' that it would normally be.
This would really matter if you had written -4000000000, as then
your array initialisation wouldn't do what you probably expect.
The easy fix is to write all the constants with 'll' after them, eg.
8000000000ll
--
- Geoffrey Keating <geoffk@cygnus.com>