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 18645 - DMD segmentation fault (Enum Initialization) #8072
Conversation
Thanks for your pull request, @JinShil! Bugzilla references
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 "stable + dmd#8072" |
Thank you! |
Tested on internal project - fixes the same problem there too. |
src/dmd/dsymbolsem.d
Outdated
@@ -2039,7 +2039,10 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor | |||
return errorReturn(); | |||
|
|||
Expression eprev = emprev.value; | |||
Type tprev = eprev.type.equals(em.ed.type) ? em.ed.memtype : eprev.type; | |||
Type tprev = | |||
eprev.type.ty == em.ed.type.ty // https://issues.dlang.org/show_bug.cgi?id=18645 |
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.
How does this prevent a seg fault? Why is equals
not working?
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.
It's trying to compare immutable(A)
to A
, causing equals
to evaluate to false. That eventually causes problems later in the semantic pass resulting in a segfault at BinExp::setNoderefOperands
.
When I compare the behavior of the compiler before the regression with the the current compiler, the change above is the precise point of diversion.
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.
Thanks, that make sense. But the proposed fix doesn't work if the type is not a leaf type. I propose instead to use:
eprev.type.toHeadMutable().equals(em.ed.type.toHeadMutable())
This technique is used elsewhere in the front end.
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.
Changed. Thank you!
No description provided.