This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Bug with "long long" and typedefs?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]