don't use memcmp() for struct equality, do memberwise comparisons per the spec#9331
don't use memcmp() for struct equality, do memberwise comparisons per the spec#9331WalterBright merged 1 commit intodlang:masterfrom
Conversation
|
Thanks for your pull request, @WalterBright! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + dmd#9331" |
|
Hmm. Needs more work. |
6d73c26 to
17dd56f
Compare
|
Who knows why these tests are failing. Can't tell anything from the logs. For one thing, the logs should STOP when there's a failure, not continue going on for thousands of lines. The thing that failed should be the last line. The tests in test/runnable are all simple to diagnose with simple logs. |
True, but not trivial to do, especially if we want to run tests concurrently.
There seems to be multiple reason. One I was able to dig out pretty easily on Windows is:
|
|
Can't repro the variant.d issue, either on Linux or Windows. Sigh. Looking at the code in variant.d, I don't see any reason for the warning, either. Can anyone else repro a problem? It's only a one line change to the compiler. |
|
@schveiguy @wilzbach as recent committers to std.variant, can you perhaps help out with what is going on here? The one line change to the compiler replaces a bit compare of struct equality with a member-wise compare for some structs. |
|
Spec reference: dlang/dlang.org#2572 |
17dd56f to
d9cca9a
Compare
|
Revised the PR so it is in conformance with the spec. |
d9cca9a to
facec04
Compare
|
I think this will need a |
facec04 to
32dfdc3
Compare
32dfdc3 to
f1cfb1e
Compare
|
Rather than wait for #9206, I just went ahead and added a |
f1cfb1e to
bfdfd3e
Compare
|
Related issue: 16216. |
bfdfd3e to
26200d6
Compare
|
@aG0aep6G Thank you, I wasn't aware of that bug report. This should fix it (but not for |
26200d6 to
4accb77
Compare
|
@wilzbach @thewilsonator ready to pull now. |
wilzbach
left a comment
There was a problem hiding this comment.
LGTM.
Though I want to point out that we shouldn't abuse the new -preview too much as we still aren't planning to do a D3 (or D 2020 (?)) in the foreseeable future (?) and thus breaking changes must still go through a deprecation phase in which the users can still compile their code, but are warned about the change.
Just by adding a -preview switch a user won't be warned that this code is affected by this breaking change.
| The spec requires that the comparison be done in a memberwise manner. | ||
| This brings the implementation in line with this. | ||
|
|
||
| $(LINK2 https://dlang.org/spec/expression.html#equality_expressions, Equality Expressions) |
There was a problem hiding this comment.
This links stands a bit out in the flow of the reader:
Maybe directly link it as e,g, "Equality Expressions can break ..."?
Isn't this more a "feature" that someone actively worked into the testsuite?
Git blame points to five years ago: |
|
The problem is I don't know how to detect that the user code would break with this. The user code that relies on the old behavior is wrong in any case. Also, the |
Before this will be turned on by default it needs to go through a deprecation period. |
My unit test runner already does this 😃: #9333. |
Introduced in PR dlang#9331, this was changed from a normal bug fix to a -preview switch because enabling it triggered a suprious "statement is not reachable" warning in Phobos. That warning has since been removed (in PR dlang#15568).
Introduced in PR dlang#9331, this was changed from a normal bug fix to a -preview switch because enabling it triggered a suprious "statement is not reachable" warning in Phobos. That warning has since been removed (in PR dlang#15568).
Introduced in PR dlang#9331, this was changed from a normal bug fix to a -preview switch because enabling it triggered a suprious "statement is not reachable" warning in Phobos. That warning has since been removed (in PR dlang#15568).
Introduced in PR dlang#9331, this was changed from a normal bug fix to a -preview switch because enabling it triggered a suprious "statement is not reachable" warning in Phobos. That warning has since been removed (in PR dlang#15568).

I.e. if the structs fit in 2 or fewer registers use a member-wise compare.