[OT] The Usual Arithmetic Confusions

Adam Ruppe destructionator at gmail.com
Fri Feb 4 23:51:54 UTC 2022


On Friday, 4 February 2022 at 23:36:11 UTC, Adam Ruppe wrote:
> I don't think you understand my proposal, which is closer to 
> C's existing rules than D is now.

To reiterate:

C's rule: int promote, DO allow narrowing implicit conversion.

D's rule: int promote, do NOT allow narrowing implicit conversion 
unless VRP passes.

My proposed rule: int promote, do NOT allow narrowing implicit 
conversion unless VRP passes OR the requested conversion is the 
same as the largest input type (with literals excluded unless 
their value is obviously out of range).


So there's no change to the actual calculation. Just loosening 
D's currently strict implicit conversion rule back to something 
closer to C's permissive standard.

There'd be zero changes to codegen. No modification of 
intermediate values. It just allows implicit conversions back to 
the input *just like C does*.


More information about the Digitalmars-d mailing list