I am compiling a piece of code where the value of the 0x8000000000000000LL literal is used to identify an unknown/unsupported value.
The LL suffix indicates that the value should be interpreted as a (signed) long long (int), but gcc (I have tried with 4.8.5 and 4.1.1) says that the value is of type unsigned long long.
I put a sample code here:
#include <stdio.h>
#define UNKNOWN 0x8000000000000000LL
int main(void){
long long value = 1000;
if ((unsigned long long) value == UNKNOWN) {
puts("Yes, they are different!!");
}
if (value == (long long) UNKNOWN) {
puts("Yes, they are different!!");
}
if (value == UNKNOWN) {
puts("Yes, they are different!!");
}
return 0;
}
The result of the compilation with this command gcc -Wsign-compare ll.c is this:
ll.c: In function ‘main’:
ll.c:16:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (value == UNKNOWN) {
^
Why is the 0x8000000000000000LL literal value considered unsigned?
