On 2025-05-16 15:48:35 +0200, Charlie Gordon wrote: > On 16 May 2025, at 14:29, Vincent Lefevre <vinc...@vinc17.net> wrote: > > This is portable because int64_t necessarily fits in a long long on > > any platform. > > This is correct, but only since C23. Previous versions of the C > Standard would have allowed `long long` to have a different > representation from `int64_t` that would not support the whole set > of values (eg: all 64-bit values except -9223372036854775808) > causing undefined behavior when this value is cast as `long long`.
Hmmm... So you mean a compiler where "long long" is a 64-bit type not represented in two's complement, but at the same time, which provides int64_t, which is necessarily represented in two's complement? But I don't think that this is conforming even in C99, which says: * in 6.2.5p8: "For any two integer types with the same signedness and different integer conversion rank (see 6.3.1.1), the range of values of the type with smaller integer conversion rank is a subrange of the values of the other type." * in 6.3.1.1p1: "The rank of any standard integer type shall be greater than the rank of any extended integer type with the same width." So, if long long and int64_t have the same width, the conversion rank of long long is greater than the rank of int64_t (6.3.1.1p1), which means that all the values of int64_t are representable in long long (6.2.5p8). -- Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon) _______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel