Re: [Tinycc-devel] Call for testing
Le dimanche 6 janvier 2013 11:28:39, Didier Barvaux a écrit : === Build of TCC GIT with Clang 3.2 === Build OK (with some warnings, I can provide them to you if you want). [SNIP] With the 'return' statement removed from the cmp_comparison_test() function, tests seem to be still KO. Example with 'test1': test1 ../tcc -B.. -DTCC_TARGET_I386 -run tcctest.c test.out1 --- test.ref 2013-01-06 10:59:06.0 +0100 +++ test.out1 2013-01-06 10:59:06.0 +0100 @@ -299,7 +299,7 @@ sizeof(+(char)'a') = 4 sizeof(-(char)'a') = 4 sizeof(~(char)'a') = 4 --66 -66 -66 -66 4294967230 4294967230 +-66 -66 -66 -66 -66 -66 0x1 0xf0f0 (nil) 0xfff0 bitfield_test:sizeof(st1) = 8 3 -1 15 -8 121 I can do other tests and/or try patches to fix that problem if you want. Interesting. I misread that first but the line with -- is the output of clang. It seems clang and gcc disagree: $ cat long_long.c #include stdio.h int main(void) { char *p = NULL; p -= 0x7042; /* from pointer to integer types */ printf(%d %d %ld %ld %lld %lld\n, (int)p, (unsigned int)p, (long)p, (unsigned long)p, (long long)p, (unsigned long long)p); return 0; } $ gcc -o long_long long_long.c ./long_long [SNIP gcc warnings] -66 -66 -66 -66 -66 -66 $ clang -o long_long long_long.c ./long_long -66 -66 -66 -66 4294967230 4294967230 So at least tcc is consistent to gcc. I'm not sure what the correct value (if any) should be though. Best regards, Thomas Preud'homme signature.asc Description: This is a digitally signed message part. ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Re: [Tinycc-devel] Call for testing
Hi, On Wed, 16 Jan 2013, Thomas Preud'homme wrote: $ cat long_long.c #include stdio.h int main(void) { char *p = NULL; p -= 0x7042; /* from pointer to integer types */ printf(%d %d %ld %ld %lld %lld\n, (int)p, (unsigned int)p, (long)p, (unsigned long)p, (long long)p, (unsigned long long)p); return 0; } Pointer to integer conversions (and back) are implementation defined, the only requirement being that if the integer type is (u)intptr_t that a pointer converted to that one and back to a pointer shall compare equal to the original pointer. So, depending on how the compiler implements this conversion (and documents this) one might get different results: $ gcc -o long_long long_long.c ./long_long [SNIP gcc warnings] -66 -66 -66 -66 -66 -66 This is a correct result for ILP32 (i.e. 32bit code). GCC sign extends pointers when the pointer representation needs fewer bits than the target type. $ clang -o long_long long_long.c ./long_long -66 -66 -66 -66 4294967230 4294967230 And this is also a correct result for 32bit code, when the compiler defines pointer to integer conversion to be zero-extending when the target type has more bits than a pointer. IMO sign-extending is more useful, and as GCC set the precedent a long time ago I would declare clang to at least have an QoI issue with compatibility with GCC. In other words: tcc has no bug here. Ciao, Michael. ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel