[dmd-beta] D2 2.058 beta

kenji hara k.hara.pg at gmail.com
Sat Feb 11 03:05:24 PST 2012


This is a lack of fixing bug 6208.
Now I'm creating a patch...

Kenji Hara
2012/02/11 19:58 "Martin Nowak" <dawg at dawgfoto.de>:

> // I.
> void foo(V)(in V v)
> {
> }
>
> // II.
> void foo(Args...)(auto ref const Args args)
> {
>    foo(args[0]);
> }
>
> void main()
> {
>    foo(10);
> }
>
> -----
>
> Deducing foo(10)
> function arguments: rvalue int
> I.  - MATCHconst
> II. - MATCHexact
>
> picks II
>
> -----
>
> Deducing foo(args[0])
> function arguments: lvalue const(int)
> I.  - MATCHexact
> II. - MATCHexact
>
> This is further disambiguated by leastAsSpecialized.
> template.c(895):
>        /* A non-variadic template is more specialized than a
>         * variadic one.
>         */
>        if (isVariadic() && !td2->isVariadic())
>
> picks I
>
> -----
>
> We end up instantiating both functions with the same argument types.
> Thus the mangling is the same and the linker will pick whatever he likes.
>
> 1. I think that variadic templates shouldn't be exact matches.
> 2. We shouldn't use tiebreakers but issue ambiguous errors.
>
> A quick fix would be to change variadic templates to MATCHconvert as in
> the attached patch.
> But I think we should reduce the complexity of template matching rather
> than patching it.
> _______________________________________________
> dmd-beta mailing list
> dmd-beta at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-beta
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-beta/attachments/20120211/861717d5/attachment-0001.html>


More information about the dmd-beta mailing list