VRP and division/remainder by 0

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Sun Jul 3 17:58:49 PDT 2016


On Sunday, July 03, 2016 23:18:58 deadalnix via Digitalmars-d wrote:
> Question is, what should VRP do when the denum range contains 0 ?
>
> I see 2 way forward:
>   - 0 will fault, so not yield a result - hardware will fault. It
> can be ignored when doing VRP.
>   - denum with 0 return a full range for division, union result's
> range while ignoring 0 and num range for remainder.
>
> Doing 1/ for division and 2/ for remainder seems to be the best
> choice to me. Thought ?

I confess that my first thought was that it should just result in an error,
since it's obviously wrong, but then you have an error that depends on how
good VRP is, which may not be a great idea. Still, I don't see any reason
why you'd want it to actually compile when it's obviously going to crash the
program if it's ever hit.

- Jonathan M Davis



More information about the Digitalmars-d mailing list