www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21721] New: error casting std.BigInts to built-in floating

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

          Issue ID: 21721
           Summary: error casting std.BigInts to built-in floating point
                    types
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: jwood13578 gmail.com

Reproducible here by going to

https://dlang.org/phobos/std_bigint.html#.BigInt.opCast

under the

const nothrow  nogc  safe T opCast(T)()
if (isFloatingPoint!T);

example entitled "Rounding when casting to floating point" and clicking Run.

This yields the following error:

Compilation output (1: )
/dlang/dmd/linux/bin64/../../src/phobos/std/bigint.d(991): Error: cannot take
address of local `resultBits` in ` safe` function `toFloat`
/dlang/dmd/linux/bin64/../../src/phobos/std/bigint.d(881): Error: template
instance `std.bigint.BigInt.toFloat!(double, "nearest")` error instantiating
onlineapp.d(41):        instantiated from here: `opCast!double`

--
Mar 15 2021