-
-
Notifications
You must be signed in to change notification settings - Fork 609
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
Conversation
|
2365837 to
77a2f24
Compare
|
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.
[REG2.064] Issue 15664 - incorrect initialisation of member of an immutable struct
[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()))) | |||
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.
@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 ?
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.
Why 2.068?
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 backporting regressions, here actually: https://github.com/tramker/dmd/tree/2.068.mart
I'm not saying it's a problem, just FYI.
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 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.
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.
OK, will do, thanks for the explanation.
[REG2.064] Issue 15664 - incorrect initialisation of member of an immutable 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 intoDtElem, type identity comparison was used to calculate array dimension, so the qualifier difference had caused wrong code.