Opened 4 years ago

Closed 4 years ago

#196 closed defect (fixed)

Forward Declaring Generic Types Crash with Dtypes

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

Description

So polymorphic types can lead to an assertion failure if there is a reference to a reference to a forward declared polymorphic type where the type parameter is a dtype.

Here is the error message:

*CFA assertion error* "baseParam == baseParams.end() && param == params.end()" from program "cfa-cpp" in "GenPoly::genericType GenPoly::makeSubstitutions(const std::__cxx11::list<TypeDecl*>&, const std::__cxx11::list<Expression*>&, std::__cxx11::list<TypeExpr*>&)" at line 268 in file "GenPoly/InstantiateGeneric.cc": Type parameters should match type variables

Here are two different ways to reproduce the error, both are pretty minimal:

forall(dtype T)
struct link;

forall(dtype T)
struct link {
    link(T) * next;
};
forall(dtype T)
struct foo;

forall(dtype U)
struct bar {
    foo(U) * data;
};

forall(dtype T)
struct foo {};

Changing the first dtype in either example to an otype will cause them to compile successfully. You can also reorder the declarations to fix them and changing the other polymorphic variable declarations doesn't change anything with most combinations.

Change History (2)

comment:1 Changed 4 years ago by ajbeach

Summary: Generic Type Declarations Crash with DtypesForward Declaring Generic Types Crash with Dtypes

I had trouble picking out the title when I was looking for it so hopefully this one is slightly clearer. Also adding sized has the same effect as converting it to otype in every case I have tried both so that is probably the key difference.

comment:2 Changed 4 years ago by ajbeach

Resolution: fixed
Status: newclosed

A fix and a test for one of the example failures has been added to master.

Note: See TracTickets for help on using tickets.