Deprecate implicit conversion between signed and unsigned integers

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Thu Feb 6 11:14:16 UTC 2025


On 07/02/2025 12:07 AM, Dom DiSc wrote:
> On Monday, 3 February 2025 at 18:40:20 UTC, Atila Neves wrote:
>> https://forum.dlang.org/post/pbhjffbxdqpdwtmcbikh@forum.dlang.org
>>
>> On Sunday, 12 May 2024 at 13:32:36 UTC, Paul Backus wrote:
>>> D inherited these implicit conversions from C and C++, where they are 
>>> widely regarded as a source of bugs.
>>>
>>> [...]
>>
>> My bias is to not like any implicit conversions of any kind, but I'm 
>> not sure I can convince Walter of that.
> 
> I think most of the problems with these implicit conversions would be 
> gone if we make this work:
> 
> ```d
>     byte a= -5;
>     ulong b = 1_000_000_000_000;
>     assert(a < b); // fails
> ```
> 
> And we already do have a solution for this (see https:// 
> issues.dlang.org/show_bug.cgi?id=259), but Walter refuses it, because it 
> will break code that relies on this bug.
> How much less likely is it to convince him of your proposal?

We should revisit this once editions are accepted.

It sounds reasonable to disable comparisons as long as VRP is kicking in 
to allow it selectively.



More information about the dip.ideas mailing list