[Issue 4988] Floats in structs are not equal on 0.0f vs -0.0f
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Oct 6 23:57:47 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4988
Don <clugdbug at yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |clugdbug at yahoo.com.au
--- Comment #1 from Don <clugdbug at yahoo.com.au> 2010-10-06 23:57:21 PDT ---
This also applies to NaNs:
assert( Foo( float.nan ) != Foo( float.nan ) ); // Works fine
auto a = Foo( float.nan );
auto b = Foo( float.nan );
assert( b != a ); // Asserts
The real problem is e2ir.c, line 2313, EqualExp::toElem(), which does a bitwise
compare for structs. That isn't valid if there are floating point numbers
inside.
This is a pain, because it needs to be considered recursively.
A quick-and-dirty fix would be to construct an opEquals whenever this happens:
clone.c StructDeclaration::needOpEquals() line 106.
if (tv->ty == Tstruct)
{ TypeStruct *ts = (TypeStruct *)tv;
StructDeclaration *sd = ts->sym;
if (sd->eq)
goto Lneed;
}
+ if (tv->isfloating())
+ goto Lneed;
}
Ldontneed:
But the problem with this is that it slows down all equality tests involving
floats. Maybe the inliner can take care of it, but generally I don't think it's
an acceptable solution.
--
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