[Issue 4988] Floats in structs are not equal on 0.0f vs -0.0f

2011-02-03 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4988


Simen Kjaeraas  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||DUPLICATE


--- Comment #3 from Simen Kjaeraas  2011-02-03 04:40:44 
PST ---
*** This issue has been marked as a duplicate of issue 3789 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4988] Floats in structs are not equal on 0.0f vs -0.0f

2010-10-07 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4988


bearophile_h...@eml.cc changed:

   What|Removed |Added

 CC||bearophile_h...@eml.cc


--- Comment #2 from bearophile_h...@eml.cc 2010-10-07 04:21:33 PDT ---
Performance is important, but correct semantics is more important.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4988] Floats in structs are not equal on 0.0f vs -0.0f

2010-10-07 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4988


Don  changed:

   What|Removed |Added

 CC||clugd...@yahoo.com.au


--- Comment #1 from Don  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: ---