[Issue 52] ambiguous function pointer silently accepted

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jul 20 23:58:17 PDT 2009


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


Don <clugdbug at yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|spec                        |patch
                 CC|                            |clugdbug at yahoo.com.au




--- Comment #9 from Don <clugdbug at yahoo.com.au>  2009-07-20 23:58:17 PDT ---

This is fixed in DMD2, and the main part of the code (with error message)
is in the DMD1 source, but not enabled (it won't compile). So it seems Walter
got halfway through fixing this, then got distracted?
(I'm removing 'spec' from the keywords, since it's clear this is just a bug).
Doing a copy-and-paste of the uniqueness test from D2, and disabling the
overload test, it _seems_ to work.
I'm assuming that the 'hasOverloads' member in D2 is for overload sets? In any
case, with this change, the D1 compiler passes the DM test suite, and the
phobos1 unit tests. Of course, if that member isn't for overload sets, this
patch isn't correct, regardless of what the tests say...
(In that case, the code relating to 'hasOverloads' should also be copied from
D2).
----

>From D2, in expression.c, in
Type *ExpInitializer::inferType(Scope *sc),
enable the code inside #if DMDV2.
But change the line:
    if (se->hasOverloads && !se->var->isFuncDeclaration()->isUnique())
into:
    if (!se->var->isFuncDeclaration()->isUnique()) 

And then in func.c, add this code from DMD2.

static int fpunique(void *param, FuncDeclaration *f)
{   FuncDeclaration **pf = (FuncDeclaration **)param;

    if (*pf)
    {    *pf = NULL;
    return 1;        // ambiguous, done
    }
    else
    {    *pf = f;
    return 0;
    }
}

FuncDeclaration *FuncDeclaration::isUnique()
{   FuncDeclaration *result = NULL;

    overloadApply(this, &fpunique, &result);
    return result;
}

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


More information about the Digitalmars-d-bugs mailing list