Skip to content

Conversation

WalterBright
Copy link
Member

@@ -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());
Copy link
Contributor

Choose a reason for hiding this comment

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

Debug message left in?

@WalterBright
Copy link
Member Author

Since this is on the regression list, it should have priority for review and pulling.

@yebblies
Copy link
Contributor

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.

@9rnsr
Copy link
Contributor

9rnsr commented Dec 30, 2013

Honestly I'm not sure why placing inferRetType functions in COMDAT section would fix the issue. If it is not an instantiated function, auto functions should be linked as exactly same as non-auto functions.

So, it looks to me that is other glue layer bug.

@WalterBright
Copy link
Member Author

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.

@WalterBright
Copy link
Member Author

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:
Copy link
Contributor

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).

@WalterBright
Copy link
Member Author

Using @9rnsr 's #3050 instead.

@WalterBright WalterBright deleted the fix11447 branch December 31, 2013 01:15
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