From: Keith.S.Thompson+u@gmail.com   
      
   Thiago Adams writes:   
   [...]   
   > Today, when the number is not represented in a signed 64 bits, in   
   > theory it should use 128 signed, but it uses 64 unsigned instead and   
   > we have a warning.   
      
   In C99 and later, an unsuffixed integer constant is *never* of unsigned   
   type.   
      
   > For instance:   
   >   
   > 9223372036854775808   
      
   That's 2**63, likely equal to LLONG_MAX+1.   
      
   > warning: integer literal is too large to be represented in a signed   
   > integer type, interpreting as unsigned [-Wimplicitly-unsigned-literal]   
   >   
   > What is interesting that C code is not portable. (nothing new, just saying)   
      
   The error message is incorrect, a bug that's been reported against gcc :   
      
   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96788   
      
   But I think that error message is from clang (gcc's message refers to   
   "integer constant", clang's to "integer literal").   
      
   The type of an unsuffixed integer constant is the first of (int,   
   long int, long long int) in which its value can be represented.   
   If it exceeds LLONG_MAX, it *may* be of an extended integer type;   
   neither gcc nor clang supports extended integer types. Failing that,   
   "the integer constant has no type", which violates a constraint:   
   "Each constant shall have a type and the value of a constant shall   
   be in the range of representable values for its type."   
      
   With 64-bit gcc, 9223372036854775808 is of type __int128 -- which (a)   
   is not an unsigned type, as stated by the incorrect warning message,   
   and (b) is *not* an extended integer type. (gcc does produce a   
   diagnostic, which is all that's required for a constraint violation,   
   but it's certainly a bug.)   
      
   With 64-bit clang, 9223372036854775808 is of type unsigned long long,   
   which is incorrect but at least consistent with the warning message.   
      
   #include    
   int main(void) {   
    printf("9223372036854775808 is of type %s\n",   
    _Generic(9223372036854775808,   
    int: "int",   
    unsigned int: "unsigned int",   
    long: "long",   
    unsigned long: "unsigned long",   
    long long: "long long",   
    unsigned long long: "unsigned long long",   
   #ifdef __GNUC__   
    __int128: "__int128",   
    unsigned __int128: "unsigned __int128",   
   #endif   
    default: ""   
    ));   
   }   
      
   --   
   Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com   
   void Void(void) { Void(); } /* The recursive call of the void */   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|