-
-
Notifications
You must be signed in to change notification settings - Fork 655
fix Issue 11447 - Closure provide bogus values #3045
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
Conversation
@@ -635,7 +635,7 @@ void FuncDeclaration::toObjFile(int multiobj) | |||
} | |||
if (!importsRoot) | |||
{ | |||
//printf("instantiated by %s %s\n", ti->instantiatingModule->toChars(), ti->toChars()); | |||
printf("instantiated by %s %s\n", ti->instantiatingModule->toChars(), ti->toChars()); |
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.
Debug message left in?
Since this is on the regression list, it should have priority for review and pulling. |
It would help if you wrote a little bit about what the problem was and why this solves it, otherwise anyone reviewing this pull has to re-discover it for themselves. |
Honestly I'm not sure why placing So, it looks to me that is other glue layer bug. |
What happens is this. "auto" for a return type means that semantic3 must be run on the function body. Running that means instantiating the template. The template refers to local symbols, so becomes a nested function. -allinst means the nested template function is written out. Nested functions always want their parents to be written out, which is the auto function in question. |
added comment to source |
@@ -673,6 +673,17 @@ void FuncDeclaration::toObjFile(int multiobj) | |||
#else | |||
s->Sclass = SCglobal; | |||
#endif | |||
/* auto return functions can be written out multiple times just like templates, because: |
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 think that all of non template functions must not be written out multiple times in object files, even if it is auto return function.
To explain my approach, I opened #3050. I'm still not sure that it can fix the original closure variable + bogus code generation issue, but at least multiple definition error is properly fixed (because the error can reproduce on win32 platform).
https://d.puremagic.com/issues/show_bug.cgi?id=11447