Opened 5 years ago

Last modified 5 years ago

#193 new defect

Monomorphization Failures outside of Functions — at Initial Version

Reported by: ajbeach Owned by:
Priority: major Component: cfa-cc
Version: 1.0 Keywords:
Cc:

Description

There are certainly multiple bugs here but currently it is unclear exactly how many there are or where the dividing lines are. Currently all of the bugs can be produced with the following set-up:

forall(dtype T) 
void poly0(T &) {}

forall(dtype T | sized(T))
void poly1(T &) {}

forall(otype T)
void poly2(T &) {}

struct wrapper {
    void (*mono)(int &);
};

The first group complain about incompatable pointer assignment inside __global_init__. It appears to be coming from C code. Note for the first case it is just a int * to void * difference but in the other cases the number of parameters is different, likely the hidden polymorphic parameters.

void (*mono0)(int &) = poly0;
void (*mono1)(int &) = poly1;
void (*mono2)(int &) = poly2;

The error messages also change if you attempt to do this for a field of a structure instead of a stand alone function pointer.

The following case produces an invalid thunk, the sizeof and alignof symbols are not defined inside of it but are used.

struct wrapper mono_wrapper1 = { poly1 };

Here there is a resolution failure as it cannot resolve a constructor. The constructor call appears to be on some generated code. I have not yet pinned down what that generated code is though.

struct wrapper mono_wrapper2 = { poly2 };

The last one compiles but I got runtime errors every time I tried to call it, an illegal operation at a very strange location.

struct wrapper mono_wrapper0 = { poly0 };

Switching from = to @= (C style initialization) changes the error message so that C compliation complains about a missing thunk. It does this for all cases.

void (*mono0c)(int &) @= poly0;
void (*mono1c)(int &) @= poly1;
void (*mono2c)(int &) @= poly2;
struct wrapper mono_wrapper0c @= { poly0 };
struct wrapper mono_wrapper1c @= { poly1 };
struct wrapper mono_wrapper2c @= { poly2 };

Change History (0)

Note: See TracTickets for help on using tickets.