Bug 18471 – std.experimental.checkedint.Checked doesn't check on assignment or construction

Status
NEW
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2018-02-19T21:32:59Z
Last change time
2024-12-01T16:32:52Z
Assigned to
petrug
Creator
Simen Kjaeraas
Moved to GitHub: phobos#10315 →

Comments

Comment #0 by simen.kjaras — 2018-02-19T21:32:59Z
When constructing or assigning to a Checked!int with a custom hook that define min and max, these min and max values are ignored. import std.experimental.checkedint; struct MyHook { enum min(T) = 3; enum max(T) = 15; static B onLowerBound(T, B)(T value, B bound) { assert(0); } static B onUpperBound(T, B)(T value, B bound) { assert(0); } } unittest { // This should trigger one of the above asserts: Checked!(int, MyHook) a = 500; // As should this: a = 22; // Instead, Checked blithely ignores the limits, and this assert triggers: assert(a != 22); }
Comment #1 by greensunny12 — 2018-06-08T09:58:09Z
Comment #2 by robert.schadek — 2024-12-01T16:32:52Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10315 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB