digitalmars.D.bugs - [Issue 4988] New: Floats in structs are not equal on 0.0f vs -0.0f
- d-bugmail puremagic.com (27/27) Oct 04 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4988
- d-bugmail puremagic.com (33/33) Oct 06 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4988
- d-bugmail puremagic.com (10/10) Oct 07 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4988
- d-bugmail puremagic.com (11/11) Feb 03 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4988
http://d.puremagic.com/issues/show_bug.cgi?id=4988 Summary: Floats in structs are not equal on 0.0f vs -0.0f Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Keywords: wrong-code Severity: critical Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: simen.kjaras gmail.com PDT --- The following code asserts: struct Foo { float data; } void bug( ) { assert( Foo( 0.0f ) == Foo( -0.0f ) ); // Works fine auto a = Foo( 0.0f ); auto b = Foo( -0.0f ); assert( b == a ); // Asserts } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 04 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4988 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug yahoo.com.au 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: -------
Oct 06 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4988 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs eml.cc 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: -------
Oct 07 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4988 Simen Kjaeraas <simen.kjaras gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |DUPLICATE 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: -------
Feb 03 2011