Bug with "long long" and typedefs?
John Zedlewski
john@adrenaline.com
Mon Jul 3 14:26:00 GMT 2000
I'm using gcc version 2.95.3 on an i686 system running Red Hat 6.1 (I think,
it might be 6.2), with Linux kernel 2.12.
The following program compiles with no command-line flags:
#include <stdio.h>
typedef long long BIG;
typedef BIG long VERYBIG;
int main(int argc, char** argv) {
VERYBIG long c = 100LL;
printf("%lld\n",c);
return 0;
}
However, it proceeds to print out a very large negative number. Is "c"
actually a "long long" in this case? It seems to me that the compiler
should give a type error and refuse to compile this, as it basically amounts
to declaring: "long long long long c", which gcc doesn't support. This came
up in real code using the Java Native interface (which typedefs "jlong" to
be "long long") when we had the typo "jlong long x" and it caused all kinds
of hell. . .
Thanks!
--JRZ
More information about the Gcc-bugs
mailing list