New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix Issue 17843 - -betterC struct with field generates references to… #7151
Conversation
Thanks for your pull request, @WalterBright! Bugzilla references
|
@@ -10,6 +10,13 @@ void test(int ij) | |||
assert(ij,"it is not zero"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That test file better be named betterc.d
;).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use grep to search for relevant test cases anyway. The filenames of the test cases aren't particularly helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed
Sounds similarly problematic, wouldn't it be better to just disable the toHash altogether? The runtime based AA is out of reach for -betterC anyhow. |
I went for disabling as little as possible. |
Can we please make sure A large part of the appeal of |
(Imho the correct fix would involve also detecting and disallowing such comparisons.) |
|
Ah, sorry – somehow I seemed to remember that this was used for opEquals as well, but that it is indeed based on the separate The change should be okay, then. But as for disabling as little as possible vs. not emitting toHash altogether: Wouldn't the same problem also occur e.g. with array members? |
I think that is a bit of a misunderstanding.
|
70adc7b
to
abbe091
Compare
Yes. Fixed. Good catch! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I still don't follow. You're modifying the function needToHash
which is used to decide whether or not TypeInfo gets an auto-generated xtoHash function.
Without TypeInfo those xtoHash/xopEquals/xopCmp functions are not accessible anyhow.
Seems much smarter to just disable the auto-generation instead.
Lines 5425 to 5427 in 2412363
sd.xeq = buildXopEquals(sd, sc2); | |
sd.xcmp = buildXopCmp(sd, sc2); | |
sd.xhash = buildXtoHash(sd, sc2); |
Furthermore you want to split the monolithic betterC switch into disableTypeInfo, disableEH, disableX right away, so we don't have to unravel that later on.
abbe091
to
42cd450
Compare
@MartinNowak I disabled the 3 functions from being generated with -betterC, but splitting the flag into multiple ones seems a bit excessive at the moment. Catching what it the flag does is pretty simple, grepping it is just a few hits. Splitting it into multiple ones means one would have to do multiple greps to see what the switch does. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm good with this. @MartinNowak ?
42cd450
to
eaf7061
Compare
cc @MartinNowak |
src/ddmd/dsymbolsem.d
Outdated
sd.xeq = buildXopEquals(sd, sc2); | ||
sd.xcmp = buildXopCmp(sd, sc2); | ||
sd.xhash = buildXtoHash(sd, sc2); | ||
if (!global.params.betterC) // these functions are used for TypeInfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to #7288, I think this should be checking the useTypeInfo
flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The splitting of the betterC options was obviously coming ;), glad it's in now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I introduced that. Please continue to enforce. :-)
90edb8e
to
6a8d964
Compare
6a8d964
to
1d2da66
Compare
… TypeInfo