[Issue 20623] New: std.conv.to!string error when argument is an inout float
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Feb 29 23:13:52 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20623
Issue ID: 20623
Summary: std.conv.to!string error when argument is an inout
float
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: trivial
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: daniele.m.bondi at gmail.com
import std.conv : to;
struct Foo
{
float f = 0f;
void foo() inout
{
to!string(this.f);
}
}
void main()
{
Foo().foo();
}
The above code causes these errors
/usr/include/dlang/dmd/std/math.d(282): Error: variable
std.math.floatTraits!(inout(float)).RECIP_EPSILON only parameters or stack
based variables can be inout
/usr/include/dlang/dmd/std/math.d(6814): Error: template instance
std.math.floatTraits!(inout(float)) error instantiating
/usr/include/dlang/dmd/std/format.d(2654): instantiated from here:
isInfinity!(inout(float))
/usr/include/dlang/dmd/std/format.d(1875): instantiated from here:
formatValueImpl!(Appender!string, inout(float), char)
/usr/include/dlang/dmd/std/conv.d(1072): instantiated from here:
formatValue!(Appender!string, inout(float), char)
/usr/include/dlang/dmd/std/conv.d(222): instantiated from here:
toImpl!(string, inout(float))
main.d(8): instantiated from here: to!(inout(float))
/usr/include/dlang/dmd/std/format.d(2694): Error: template instance
std.math.signbit!(inout(float)) error instantiating
/usr/include/dlang/dmd/std/format.d(1875): instantiated from here:
formatValueImpl!(Appender!string, inout(float), char)
/usr/include/dlang/dmd/std/conv.d(1072): instantiated from here:
formatValue!(Appender!string, inout(float), char)
/usr/include/dlang/dmd/std/conv.d(222): instantiated from here:
toImpl!(string, inout(float))
main.d(8): instantiated from here: to!(inout(float))
/usr/include/dlang/dmd/std/format.d(2732): Error: forward reference to inferred
return type of function call function () @trusted
{
import core.stdc.stdio : snprintf;
return snprintf(buf2.ptr, buf2.length, sprintfSpec.ptr, fs.width, fs.precision
== fs.UNSPECIFIED ? -1 : fs.precision, tval);
}
()
I tried adding Unqual! to the declaration of RECIP_EPSILON and the error seems
to go away
--
More information about the Digitalmars-d-bugs
mailing list