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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


--- Comment #4 from Don <clugd...@yahoo.com.au> 2010-08-18 06:37:38 PDT ---
This is caused by a confusion in the code for deduceFunctionTemplateMatch.
The comment and loop condition implies that we're looping over the function
_parameters_. But the rest of the loop assumes it's a loop over the function
_arguments_.
In the case where the tuple is of length zero, an infinite loop results.
Apart from the ICE, this also causes valid code to be rejected. 
------
void bug4652(U, T...)(long y, T x, U num){}
void instantiate4652()
{
    bug4652(2, 'c', 27, 'e', 'f',1); // rejects-valid
    bug4652(2, 1);  // infinite loop on valid code
}
----

PATCH: template.c line 1090. Replace the first section of code, with the
second.
---------------
    // Loop through the function parameters
    for (i = 0; i < nfparams; i++)
    {
        /* Skip over function parameters which wound up
         * as part of a template tuple parameter.
         */
        if (i == fptupindex)
        {   if (fptupindex == nfparams - 1)
                break;
            i += tuple_dim - 1;
            continue;
        }

        Parameter *fparam = Parameter::getNth(fparameters, i);
---------------
    // Loop through the function arguments
    for (i = 0; i < nfargs; i++)
    {
        /* Skip over function parameters which wound up
         * as part of a template tuple parameter.
         */
        if (i >= fptupindex && i< fptupindex+tuple_dim)
            continue;
        /* Function parameters correspond to function arguments as follows.
         * Note that tuple_dim may be zero.
         * arg [0..fptupindex] == param[0..fptupindex]
         * arg [fptupindex..fptupindex+tuple_dim] == param[fptupindex]
         * arg[fputupindex+dim..nfargs] == param[fptupindex+1..nfparams]
         */
        size_t parami = i;
        if (fptupindex >= 0 && i >= fptupindex) {
            parami -= tuple_dim-1;
        }
        Parameter *fparam = Parameter::getNth(fparameters, parami);
--------

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

Reply via email to