Opened 3 years ago

#218 new defect

Distributed Qualifiers Change Signature

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

Description

Using distributed forall qualifiers (the others seem to be fine) can change how a function is resolved and how a name is mangled.

So they most obvious example we have currently is this one:

forall( otype T ) {
    forall( | { T ?+?( T, T ); } ) {
        forall( | { T ?-?( T, T ); } ) {
            T fred( T t );
        }
    }
}

forall( otype T ) {
    forall( | { T ?-?( T, T ); } ) {
        forall( | { T ?+?( T, T ); } ) {
            T fred( T t ) { return t + t - t; }
        }
    }
}

int main() {
    int i = fred( 3 );
}

Although this should be one function, forward declared and fully defined, the resolver sees it as two almost identical functions and they are ambiguous. So we get a resolution error.

The one that lead me onto this error is actually much quieter add may be a different problem (further investigation is required).

forall(dtype T)
struct unique_ptr {
    T * data;
};

forall(dtype T) {
    forall( | { void ^?{}(T &); })
    void move(unique_ptr(T) & this, unique_ptr(T) & that);
}

forall(dtype T | { void ^?{}(T &); })
void move(unique_ptr(T) & this, unique_ptr(T) & that) {
    // ...
}

This is from the memory.hfa/cfa module in the standard library. Anyways the resolver doesn't seem to notice any difference between these two. Instead it gets all the way through resolution and the difference only shows up during name mangling where the names come out slightly differently.

_X4moveQ2_0_0_1__X11_destructorFv_BD0__Fv_S10unique_ptr_BD0_S10unique_ptr_BD0___1

_X4moveQ1_0_0_1__X11_destructorFv_BD0__Fv_S10unique_ptr_BD0_S10unique_ptr_BD0___1

If they are in the same file the call seems to pick the one with a body and everything is fine. If the forward declaration is in a header and the full declaration is in a code file then building will fail on linking.

Change History (0)

Note: See TracTickets for help on using tickets.