Bug 17302 – [SPEC] QualifiedName mangling does not match compiler.

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-04-07T21:44:59Z
Last change time
2017-10-28T15:26:49Z
Keywords
mangling, pull
Assigned to
No Owner
Creator
Iain Buclaw

Comments

Comment #0 by ibuclaw — 2017-04-07T21:44:59Z
I think I saw this somewhere, but couldn't find the bug report. Nested functions have their parent's parameters encoded into the mangle symbol. --- void foo() { void bar() { } pragma(msg, bar.mangleof); } --- _D4test3fooFZ3barMFNaNbNiNfZv Where 'FZ' is inserted between 3foo and 3bar. This is contrary to the spec (removed irrelevant bits that match template and internal symbols): --- MangledName: _D QualifiedName M Type QualifiedName: SymbolName SymbolName QualifiedName SymbolName: LName LName: Number Name --- From the spec, I can only infer that the symbol should be: _D4test3foo3barMFNaNbNiNfZv Otherwise a special rule needs to be added to handle functions in SymbolName as well as TemplateInstanceName. But that will just cause grammar ambiguities with LName. SymbolName: FunctionName LName FunctionName: Number Name Type LName: Number Name Well... there's *already* a grammar ambiguity as #14591 is somewhat related.
Comment #1 by ibuclaw — 2017-04-07T21:59:24Z
And fixing 12352 would be the cause of this bug.
Comment #2 by r.sagitario — 2017-04-08T15:23:42Z
I think it's correct to add argument types of the outer functions to the mangling of nested symbols. Otherwise symbols in different overloads get the same mangled name, possibly causing silent errors (due to COMDAT selection). The return type can be omitted, though.
Comment #3 by r.sagitario — 2017-04-08T15:50:45Z
Comment #4 by r.sagitario — 2017-10-28T13:47:18Z