Mixing operations with signed and unsigned types
bearophileHUGS at lycos.com
Wed Jun 30 13:56:52 PDT 2010
> what you seem to be suggesting is that size_t be the same as ptrdiff_t.
Yes, but an unsigned word type needs to be kept in the language.
> There is, however, another problem: signed types convert implicitly to
> unsigned types, though they do generate a warning if compiled with -w
> (except peculiarly for int/uint). Removing this implicit conversion
> would break certain existing code that uses signed types where it should
> be using unsigned.
> If we also change array indices to be signed, it
> would break that code that sensibly uses unsigned types, which is
> probably worse.
Yes, of course that code needs to be fixed after the change I have suggested. A "breaking change" means that some of the old code needs to be fixed.
More information about the Digitalmars-d-learn