Make size_t its own type

IchorDev zxinsworld at gmail.com
Thu Jan 30 11:15:35 UTC 2025


On Thursday, 23 January 2025 at 16:00:20 UTC, Quirin Schroll 
wrote:
> If `size_t` were its own type, the language could reject any 
> implicit conversion that would fail on any target supported by 
> the compiler / the language.

In general, having to cross-compile your code to make sure that 
it works sucks and is something I would expect from a 
non-portability-friendly language like C. Making `size_t` its own 
type would greatly benefit code portability for people who aren’t 
actively testing their code on 32-bit platforms (personally I 
don’t own any 32-bit computers, so I can’t test for issues like 
that). I wholly agree that the same logic should be applied to 
`ptrdiff_t`, as dukc said.
Technically this change would cause a lot of existing code to no 
longer compile, but fixing it would be as simple as adding 
explicit casts where necessary; and that code would not have 
compiling for either 32- or 64-bit machines anyway.


More information about the dip.ideas mailing list