Opened 7 years ago

Closed 6 years ago

#27 closed defect (fixed)

Thunks are not generated for polymorphic-to-monomorphic function casts.

Reported by: pabuhr Owned by: Rob Schluntz <rschlunt@…>
Priority: major Component: cfa-cc
Version: 1.0 Keywords:
Cc:

Description

Thunks are not generated for polymorphic-to-monomorphic function casts, e.g.

forall(otype T) T f(T);

void g() {
    (int (*)(int))f;    // casts, doesn't convert
    int (*h)(int) = f;  // casts incorrectly, doesn't convert either
}

Aaron: I suspect this needs to be fixed with a change to the GenPoly::box pass
There is a bug there, but it exposes deeper issues in the resolution pass;
essentially, cfa-cc seems to have no concept of a compiler-generated implicit
conversion (it punts to GCC whenever one is needed that exists in C), and it doesn't
keep the right information in the correct places for an easy fix for this bug. I'd
suggest resolving this one WONTFIX.

Change History (3)

comment:1 Changed 7 years ago by a3moss

I beat my head off this one for three weeks when I started on Cforall, and eventually gave up, for the reasons you mention.

I'd defer resolution on this one until the new resolver is in, and we've clarified what "user-defined conversions" look like in Cforall (or even if they exist).

comment:2 Changed 6 years ago by Rob Schluntz

While working on related bugs and cleanup, I actually managed to get this one working without too much trouble by moving the inferred parameters from ApplicationExpr to the Expression base class. Then it was just a matter of calling the right functions in the right places.

comment:3 Changed 6 years ago by Rob Schluntz <rschlunt@…>

Owner: set to Rob Schluntz <rschlunt@…>
Resolution: fixed
Status: newclosed

In bb666f6:

Fix polymorphic-to-monomorphic function specialization for casts and initializers [fixes #27]

Note: See TracTickets for help on using tickets.