www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20708] New: result of cast not specified when value is out of

https://issues.dlang.org/show_bug.cgi?id=20708

          Issue ID: 20708
           Summary: result of cast not specified when value is out of
                    range
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: johanengelen weka.io

The specification says nothing about what the result of a numeric cast is when
the value is outside the receiving type's range.

For example:
```
uint a = 260;
auto b = cast(ubyte) a;

float f = 1.203125f  * 255.0f;
auto zz =  cast(ubyte) f;
```

Not having the result specified currently means that it is treated as UB by LDC
and GDC.

--
Mar 29 2020