This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
long long int array warning
- To: "'gcc-bugs at gcc dot gnu dot org'" <gcc-bugs at gcc dot gnu dot org>
- Subject: long long int array warning
- From: ehallick at mail dot cpm dot com (Erick Hallick)
- Date: Tue, 13 Jun 2000 09:50:15 -0500
- Encoding: 60 TEXT
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
However, then I execute the program, it appears that the array has been
assigned correctly. Here is the output:
ehallick@netfinity:~ > ./a.out
a[0] = 1
a[1] = 2
a[2] = 2000000000
a[3] = 4000000000
a[4] = 8000000000
a[5] = -8000000000
I've tried casting the constants to (long long int), but that doesn't get
rid of the warning. Does anyone know if I'm doing anything incorrectly?
Many thanks in advance,
P.S:
ehallick@netfinity:~ > gcc -v
Reading specs from /usr/lib/gcc-lib/i486-suse-linux/2.95.2/specs
gcc version 2.95.2 19991024 (release)
Erick Hallick
Director, Information Systems and Services
CPM Corporation - http://www.cpm.com
Email: ehallick@cpm.com
Phone: (608) 236-0475 x30
FAX: (608) 236-0485