http://d.puremagic.com/issues/show_bug.cgi?id=3366


Don <clugd...@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                 CC|                            |clugd...@yahoo.com.au
            Summary|Crash by variadic member    |Segfault(declaration.c)
                   |function templates          |variadic template with
                   |                            |unmatched constraint


--- Comment #1 from Don <clugd...@yahoo.com.au> 2009-10-07 00:22:00 PDT ---
Reduced test case:

void f(T...)() if (T.length > 20){}
void main(){
    f!(int, int)();
}

If the tuple length isn't used in the constraint, there's no ICE, but you get
the same silly error message about "T is already defined". It only happens if
the function has no parameters, and when there is no match.

It thinks T is already defined, because in the code which is patched below,
it's trying to pass an empty tuple for T. But it's already worked out what T
must be (in this case (int, int)). So it gets horribly confused.

Root cause: deduceFunctionTemplateMatch() missed this case.

PATCH:
template.c, deduceFunctionTemplateMatch(), line 885.
----------------
    /* Check for match of function arguments with variadic template
     * parameter, such as:
     *
     * template Foo(T, A...) { void Foo(T t, A a); }
     * void main() { Foo(1,2,3); }
     */
    if (tp)                // if variadic
    {
-    if (nfparams == 0)        // if no function parameters
+    if (nfparams == 0 && nfargs!=0)        // if no function parameters
    {
        Tuple *t = new Tuple();
        //printf("t = %p\n", t);
        dedargs->data[parameters->dim - 1] = (void *)t;
        declareParameter(paramscope, tp, t);
        goto L2;
    }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to