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.064] Issue 15664 - incorrect initialisation of member of an immutable struct #5440

Merged
merged 1 commit into from
Feb 23, 2016

Conversation

9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented Feb 11, 2016

When a struct literal appears in dataseg or TLS variable initialization, its elements StructLiteralExp.elements[i] are also painted to the qualifier of constructed struct type. But in toDtElem, type identity comparison was used to calculate array dimension, so the qualifier difference had caused wrong code.

@dlang-bot
Copy link
Contributor

Fix Bugzilla Description
15664 [REG2.064] incorrect initialisation of member of an immutable struct

@9rnsr 9rnsr force-pushed the fix15664 branch 2 times, most recently from 2365837 to 77a2f24 Compare February 16, 2016 23:15
@MartinNowak
Copy link
Member

Auto-merge toggled on

…struct

When a struct literal appears in dataseg or TLS variable initialization, its elements `StructLiteralExp.elements[i]` are also painted to the qualifier of constructed struct type. But in `toDtElem`, type identity comparison was used to calculate array dimension, so the qualifier difference had caused wrong code.
MartinNowak added a commit that referenced this pull request Feb 23, 2016
[REG2.064] Issue 15664 - incorrect initialisation of member of an immutable struct
@MartinNowak MartinNowak merged commit cf67084 into dlang:stable Feb 23, 2016
@9rnsr 9rnsr deleted the fix15664 branch February 24, 2016 01:21
tramker pushed a commit to tramker/dmd that referenced this pull request Mar 11, 2016
[REG2.064] Issue 15664 - incorrect initialisation of member of an immutable struct
@@ -896,7 +896,7 @@ dt_t **toDtElem(TypeSArray *tsa, dt_t **pdt, Expression *e)
pdt = dtend(pdt);
Type *tnext = tsa->next;
Type *tbn = tnext->toBasetype();
while (tbn->ty == Tsarray && (!e || tbn != e->type->nextOf()))
while (tbn->ty == Tsarray && (!e || !tbn->equivalent(e->type->nextOf())))
Copy link
Contributor

Choose a reason for hiding this comment

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

@9rnsr, I've tried this patch in 2.068 and it segfaults, because e->type->nextOf() is null. Maybe there should be a check for it ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why 2.068?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm backporting regressions, here actually: https://github.com/tramker/dmd/tree/2.068.mart
I'm not saying it's a problem, just FYI.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The existence of e->type->nextOf() is guaranteed by CTFE interpretation of dataseg variable initializer in 2.070. I guess it had not been guaranteed yet in 2.068.
So, if you want to backport this patch to 2.068, you would need to add e->type->nextOf() null check AND adjust the len calculation.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, will do, thanks for the explanation.

tramker added a commit to tramker/dmd that referenced this pull request Mar 13, 2016
[REG2.064] Issue 15664 - incorrect initialisation of member of an immutable struct
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.

4 participants