long long int array warning
Erick Hallick
ehallick@mail.cpm.com
Tue Jun 13 07:47:00 GMT 2000
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
More information about the Gcc-bugs
mailing list