[Issue 20743] New: Checked!(int, Abort) does not abort but raise SIGFPE
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Apr 17 00:08:05 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20743
Issue ID: 20743
Summary: Checked!(int, Abort) does not abort but raise SIGFPE
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: kdevel at vogtner.de
```
import std.experimental.checkedint;
alias cint = Checked!(int, Abort);
void works_okay ()
{
cint a = cint.max;
cint b = 1;
cint c = a + b;
}
void raises_sigfpe_instead ()
{
cint a = cint.min;
cint b = -1;
cint c = a / b;
}
void main ()
{
import std.stdio;
foreach (f; [&works_okay, &raises_sigfpe_instead])
try f ();
catch (Throwable e)
writefln ("caught Throwable <%s>", e.msg);
}
```
Application output
Overflow on binary operator: int(2147483647) + const(int)(1)
caught Throwable <Assertion failure>
Overflow on binary operator: int(-2147483648) / const(int)(-1)
Error: program killed by signal 8
--
More information about the Digitalmars-d-bugs
mailing list