Skip to content
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

[REG2.066] Issue 15422 - associative array of nested struct - crash on usage #5308

Closed
wants to merge 3 commits into from

Conversation

9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented Dec 14, 2015

If a struct is nested in a class, its vthis will be reference to the parent class, and struct default equality and hashing considers the parent class equality and hashing.
Otherwise, the vthis will be typed as void*, and pointer equality and hashing is merely used.


The root problem is an incorrect type for the struct vthis field. It has been already filed as Issue 14442, so this PR fixes it, and then issue 15422 will be fixed naturally.

@dlang-bot
Copy link
Contributor

Fix Bugzilla Description
14442 Wrong this.outer reference in nested classes
15422 [REG2.066] associative array of nested struct - crash on usage

9rnsr referenced this pull request in 9rnsr/dmd Dec 14, 2015
On a nested struct, built-in generated equality (`tupleof` comparison), hashing (static `xtoHash` function), and assignment (implicitly added `opAssign`) should use its enclosing context identity.
if (i == 2) tthis = ad.type.immutableOf();
if (i == 3) tthis = ad.type.sharedOf();
if (i == 4) tthis = ad.type.sharedConstOf();
if (i == 5) break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for (size_t i = 0; i < 5; i++) then turn this into a final switch statement?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. When I wrote this code, I thought that other qualifiers (inout, inout const, shared inout etc) might need to be tested here.

@MartinNowak
Copy link
Member

What's the state of this?

@WalterBright
Copy link
Member

Please submit the hundreds of lines of reformatting and refactoring as a separate PR.

9rnsr added 3 commits January 31, 2016 23:28
If a struct is nested in a class, its `vthis` will be reference to the parent class, and struct default equality and hashing considers the parent class equality and hashing.
Otherwise, the `vthis` will be typed as void*, and pointer equality and hashing is merely used.
@9rnsr
Copy link
Contributor Author

9rnsr commented Feb 1, 2016

Superseded by #5391. It also drops style changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants