[Issue 6574] Erroneous recursive call in template instantiation

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jan 9 02:13:44 PST 2015


https://issues.dlang.org/show_bug.cgi?id=6574

Kenji Hara <k.hara.pg at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |spec, wrong-code
           Severity|major                       |critical

--- Comment #4 from Kenji Hara <k.hara.pg at gmail.com> ---
This is a mangling scheme issue and function symbol is confused in link stage.

module test;
extern(C) int printf(const char*, ...);
enum Method { A, B, }

void foo(Method method = Method.A)()
{
    pragma(msg, "1: ", foo.mangleof);
    foo!method();
}
void foo(Method method : Method.A)()
{
    pragma(msg, "2: ", foo.mangleof);
}
void main()
{
    foo();
}

foo() instantiates the first version `void foo(Method method = Method.A)()`,
then it instantiates the second version `void foo(Method method : Method.A)()`.

But the instantiated two functions have exactly same mangled names, so the
pragmas print:

1: _D4test24__T3fooVE4test6Methodi1Z3fooFZv
2: _D4test24__T3fooVE4test6Methodi1Z3fooFZv

and the foo!method() wrongly call itself.

--


More information about the Digitalmars-d-bugs mailing list