On 22/03/21 11:59, Stefano Garzarella wrote:
If I build with gcc 10.2.1 20210313 (Alpine 10.2.1_pre2) uint64_t and UINT64_C(1) have a size of 4 bytes, while UINT64_C(0x2052545020445352) has a size of 8 bytes: warning: initialization of ‘char (*)[4]’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion] 74 | char (*__size1)[sizeof(uint64_t)] = 1; | ^ warning: initialization of ‘char (*)[4]’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion] 75 | char (*__size2)[sizeof(UINT64_C(1))] = 1; | ^ warning: initialization of ‘char (*)[8]’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion] 76 | char (*__size3)[sizeof(UINT64_C(0x2052545020445352))] = 1;
Looks like long is 4 bytes long with -m16 and -m32, but 8 bytes with -m64. The large constant is extended to long long because it's the only way to fit it.
Paolo