The case for integer overflow checks?

Dennis Cote private at
Mon Sep 18 22:32:28 UTC 2017

On Monday, 18 September 2017 at 13:25:55 UTC, Andrei Alexandrescu 
> For the record, with the help of std.experimental.checkedint, 
> the change that fixes the code would be:
> malloc(width * height * 4) ==> malloc((checked(width) * height 
> * 4).get)
> That aborts the application with a message if a multiplication 
> overflows.

Can it do something other than abort? Can it throw an overflow 
exception that could be caught to report the error and continue?

Dennis Cote

More information about the Digitalmars-d mailing list