D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 12831 - assert incorrectly fails on to!float conversion
Summary: assert incorrectly fails on to!float conversion
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 All
: P1 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-01 01:57 UTC by Martin Krejcirik
Modified: 2014-06-01 13:23 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Martin Krejcirik 2014-06-01 01:57:22 UTC
import std.conv;

void main()
{
    float a = 1.234f;
    float b = to!float("1.234");
    assert (a == b);
    assert (a == to!float("1.234")); //fails
}

DMD32 D Compiler v2.066-devel-38c5c36

Works in gdc. Also works with real.
Comment 1 Martin Krejcirik 2014-06-01 02:12:12 UTC
import std.conv;

void main()
{
    float a = 1.234f;
    real b = to!float("1.234");
    assert (a == b); //fails
}

Maybe I'm missing something about fpu arithmetics, this fails too, but again works in gdc.
Comment 2 Martin Krejcirik 2014-06-01 13:23:38 UTC
marking INVALID as floating point numbers shouldn't be compared directly for equality (machine and platform dependent).