Bug in ^^

Vladimir Panteleev thecybershadow.lists at gmail.com
Tue Sep 17 18:02:59 UTC 2019

On Tuesday, 17 September 2019 at 17:51:59 UTC, Johan Engelen 
> On Tuesday, 17 September 2019 at 17:41:23 UTC, Vladimir 
> Panteleev wrote:
>> I agree, a warning or error for overflows at compile-time 
>> would be appropriate.
> Do you have a suggestion for the syntax to write overflowing 
> CTFE code without triggering the warning?

When a bigger type exists which fits the non-overflown result, 
the obvious solution is to make one of the operands of that type, 
then explicitly cast the result back to the smaller one.

When a bigger type does not exist, explicit overflow could be 
indicated by using binary-and with the type's full bit mask, i.e. 
`(1_000_000 * 1_000_000) & 0xFFFFFFFF`. This fits with D's 
existing range propagation logic, i.e. the following is not an 

	uint i = void;
	ubyte b = i & 0xFF;

More information about the Digitalmars-d mailing list