Bug 21721 – casting std.BigInts to built-in floating point types doesn't work without -preview=dip1000
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-03-15T19:34:54Z
Last change time
2021-04-27T09:42:42Z
Keywords
pull
Assigned to
No Owner
Creator
jwood13578
Comments
Comment #0 by jwood13578 — 2021-03-15T19:34:54Z
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`
Comment #1 by dlang-bot — 2021-03-18T06:07:40Z
@n8sh created dlang/phobos pull request #7877 "casting std.BigInts to built-in floating point types not allowed in `@safe` code without -preview=dip1000" fixing this issue:
- Fix Issue 21721 - casting std.BigInts to built-in floating point types not allowed in `@safe` code without -preview=dip1000
https://github.com/dlang/phobos/pull/7877
Comment #2 by dlang-bot — 2021-03-18T07:34:25Z
dlang/phobos pull request #7877 "casting std.BigInts to built-in floating point types not allowed in `@safe` code without -preview=dip1000" was merged into stable:
- 37cc1f7168ddd387ea220c8397b25b6f01759b06 by Nathan Sashihara:
Fix Issue 21721 - casting std.BigInts to built-in floating point types not allowed in `@safe` code without -preview=dip1000
https://github.com/dlang/phobos/pull/7877
Comment #3 by dlang-bot — 2021-04-25T13:46:02Z
dlang/phobos pull request #7964 "merge stable" was merged into master:
- d3a14339217b1f54060ee2457e9cd8fc64651633 by Nathan Sashihara:
Fix Issue 21721 - casting std.BigInts to built-in floating point types not allowed in `@safe` code without -preview=dip1000
https://github.com/dlang/phobos/pull/7964
Comment #4 by dlang-bot — 2021-04-27T09:42:42Z
dlang/phobos pull request #8012 "merge stable" was merged into master:
- 40b34d3c1ff1d6bf8c75114c2c47d96c4864686f by Nathan Sashihara:
Fix Issue 21721 - casting std.BigInts to built-in floating point types not allowed in `@safe` code without -preview=dip1000
https://github.com/dlang/phobos/pull/8012