[clang] [Clang] Make the result type of sizeof/pointer subtraction/size_t lit… (PR #136542)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 23 11:01:02 PDT 2025


AaronBallman wrote:

> That is not possible, and this is exactly what I'm worried about with all this discussion about making `size_t` more "built-in". `size_t` is specified to be a typedef of a (platform-dependent) standard integer type, and it needs to continue to behave that way; we cannot actually make it a different type, no matter how much cleaner we personally think the language would be if it were. That is not fundamentally changed by the committee adding the `%z` format specifier or `19z` literals or anything like that.

Er, I feel like I must be missing something, because I think we can do this. `size_t` is defined to be an implementation-defined unsigned integer type. It is *not* required to be defined to `unsigned int` or `unsigned long`, etc explicitly, or even a standard integer type at all. So I think we can define it to be `__size_t`, so long as that type is compatible with the platform-specific underlying type.

https://github.com/llvm/llvm-project/pull/136542


More information about the cfe-commits mailing list