Thread overview | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
February 09, 2010 [Issue 3789] New: comparing a struct with an array member does a bitwise compare | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=3789 Summary: comparing a struct with an array member does a bitwise compare Product: D Version: 2.040 Platform: Other OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: schveiguy@yahoo.com --- Comment #0 from Steven Schveighoffer <schveiguy@yahoo.com> 2010-02-09 12:08:23 PST --- If you have a struct that does not define opEquals, but which contains a member that defines opEquals, that member's opEquals is called when comparing the struct. However, arrays are still bitwise compared. Example: struct String { char[] data; } void main () { auto foo = String("foo".dup); auto bar = String("foo".dup); assert(bar.data == foo.data); assert(bar == foo, "oops structs aren't equal"); } results in the second assert failing. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 09, 2010 [Issue 3789] comparing a struct with an array member does a bitwise compare | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | http://d.puremagic.com/issues/show_bug.cgi?id=3789 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug@yahoo.com.au --- Comment #1 from Don <clugdbug@yahoo.com.au> 2010-02-09 13:53:32 PST --- Arrays don't have a an opEquals overloaded operator. What's the bug? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 09, 2010 [Issue 3789] comparing a struct with an array member does a bitwise compare | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | http://d.puremagic.com/issues/show_bug.cgi?id=3789 --- Comment #2 from Steven Schveighoffer <schveiguy@yahoo.com> 2010-02-09 14:37:33 PST --- that is an unimportant technical difference. The semantic meaning of the feature is that if you have a type T, and a struct S fully defined as: struct S { T member; } Then this assert should always pass: S s1, s2; ... // initialize s1 and s2 to whatever you want assert((s1 == s2) is (s1.member == s2.member)); Bitwise compare happens to be the comparison operator for all builtins except for floating point and arrays. Although opEquals isn't defined, they certainly have special comparison operators, and those should be invoked when comparing containing structs. This is the principle of least surprise, especially when arrays back types like strings. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 10, 2010 [Issue 3789] comparing a struct with an array member does a bitwise compare | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | http://d.puremagic.com/issues/show_bug.cgi?id=3789 iorlas <denis.tomilin@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |denis.tomilin@gmail.com --- Comment #3 from iorlas <denis.tomilin@gmail.com> 2010-02-09 18:31:35 PST --- (In reply to comment #1) > Arrays don't have a an opEquals overloaded operator. What's the bug? Not a bug, only not implemented part of comparison. Ofc it must be. Throws error or comparison each element through opEqual of elements type. Maybe now its not a critical, but in future it can block some code. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 03, 2011 [Issue 3789] comparing a struct with an array member does a bitwise compare | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | http://d.puremagic.com/issues/show_bug.cgi?id=3789 Simen Kjaeraas <simen.kjaras@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dsimcha@yahoo.com --- Comment #4 from Simen Kjaeraas <simen.kjaras@gmail.com> 2011-02-03 04:40:42 PST --- *** Issue 5313 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 03, 2011 [Issue 3789] comparing a struct with an array member does a bitwise compare | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | http://d.puremagic.com/issues/show_bug.cgi?id=3789 Simen Kjaeraas <simen.kjaras@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dsimcha@yahoo.com CC| |simen.kjaras@gmail.com --- Comment #4 from Simen Kjaeraas <simen.kjaras@gmail.com> 2011-02-03 04:40:42 PST --- *** Issue 5313 has been marked as a duplicate of this issue. *** --- Comment #5 from Simen Kjaeraas <simen.kjaras@gmail.com> 2011-02-03 04:40:44 PST --- *** Issue 4988 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 03, 2011 [Issue 3789] Structs members that require non-bitwise comparison not correctly compared | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | http://d.puremagic.com/issues/show_bug.cgi?id=3789 Simen Kjaeraas <simen.kjaras@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code Version|2.040 |D2 Summary|comparing a struct with an |Structs members that |array member does a bitwise |require non-bitwise |compare |comparison not correctly | |compared Severity|normal |major --- Comment #6 from Simen Kjaeraas <simen.kjaras@gmail.com> 2011-02-03 04:42:24 PST --- Making this the main bug for erroneous bitwise comparison of structs. There were at least 4 in total. List of things that do not work: floating-point members array members (including strings) List of things that do work: any member that uses bitwise comparison member structs that have overloaded opEquals The latter suggests that this should work for floating point numbers and arrays too. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 04, 2011 [Issue 3789] Structs members that require non-bitwise comparison not correctly compared | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | http://d.puremagic.com/issues/show_bug.cgi?id=3789 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs@eml.cc --- Comment #7 from bearophile_hugs@eml.cc 2011-02-04 12:17:46 PST --- Maybe issue 5519 should be merged with this one. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 04, 2011 [Issue 3789] Structs members that require non-bitwise comparison not correctly compared | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | http://d.puremagic.com/issues/show_bug.cgi?id=3789 --- Comment #8 from Simen Kjaeraas <simen.kjaras@gmail.com> 2011-02-04 13:52:43 PST --- *** Issue 5519 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 14, 2011 [Issue 3789] Structs members that require non-bitwise comparison not correctly compared | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | http://d.puremagic.com/issues/show_bug.cgi?id=3789 --- Comment #9 from Kenji Hara <k.hara.pg@gmail.com> 2011-10-13 23:22:29 PDT --- *** Issue 6812 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation