boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

344-integer-literal-types.c (969B)


      1 /* Integer suffixes must select types from the active ILP32/LP64 candidate
      2  * lists. In particular, a small LL/ULL constant is still 64-bit on RV32. */
      3 int main(void)
      4 {
      5     if (sizeof(1) != sizeof(int)) return 1;
      6     if (sizeof(1U) != sizeof(unsigned int)) return 2;
      7     if (sizeof(1L) != sizeof(long)) return 3;
      8     if (sizeof(1UL) != sizeof(unsigned long)) return 4;
      9     if (sizeof(1LL) != sizeof(long long)) return 5;
     10     if (sizeof(1ULL) != sizeof(unsigned long long)) return 6;
     11 
     12     /* Unsuffixed decimal cannot select unsigned int, while a hex constant
     13      * tests int, unsigned int, long, ... in that order. */
     14     if (sizeof(2147483648) != 8) return 7;
     15     if (sizeof(0xffffffff) != sizeof(unsigned int)) return 8;
     16     if (0xffffffff < 0) return 9;
     17 
     18     /* ILP32 converts this pair to unsigned long; LP64 keeps signed long. */
     19     if (sizeof(long) == 4) {
     20         if (-1L < 1U) return 10;
     21     } else {
     22         if (!(-1L < 1U)) return 11;
     23     }
     24     return 0;
     25 }