[Issue 3520] std.numeric.CustomFloat horribly broken
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Apr 8 09:30:59 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3520
Rob Jacques <sandford at jhu.edu> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |sandford at jhu.edu
Severity|normal |regression
--- Comment #3 from Rob Jacques <sandford at jhu.edu> 2010-04-08 09:30:55 PDT ---
There seems to be an additional problem with custom float. In DMD 2.039 and
2.042 it doesn't compile. I've developed a hack/patch around this issue.
For example:
CustomFloat!(1, 5, 10) temp;
Error: this for signfractionexponent needs to be type CustomFloat not type
CustomFloat!(1,5,10)
Error: struct std.numeric.CustomFloat!(1,5,10).CustomFloat member
signfractionexponent is not accessible
Error: template instance std.numeric.CustomFloat!(1,5,10) error instantiating
I've been able to reduce the code to a test case
struct CustomFloat(
bool signBit,
uint fractionBits,
uint exponentBits,
// uint bias = (1u << (exponentBits - 1)) - 1 // This is the problem
CustomFloatFlags flags = CustomFloatFlags.all
)
{
float foo;
float bar() { return foo;}
F get(F)() { return 1; }
}
however, when I try this as independent test case, the bug isn't reproduced.
As a quick patch I've move bias from a template parameter to the struct body as
an enum:
struct CustomFloat(
bool signBit, // allocate a sign bit? (true for float)
uint fractionBits, // fraction bits (23 for float)
uint exponentBits,
// uint bias = (1u << (exponentBits - 1)) - 1
CustomFloatFlags flags = CustomFloatFlags.all)
{
enum bias = (1u << (exponentBits - 1)) - 1;
...
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list