﻿id	summary	reporter	owner	description	type	status	priority	component	version	resolution	keywords	cc
304	Polymorphic self reference does not work	mlbrooks		"{{{
    forall( tE & )
    struct thing {
        thing(tE) *a;
        thing(tE) *b;
    };
}}}

Actual: cfa emits bad code: gcc reports parse errors

Expected: compiles (-c) successfully

Observation:  `cfa -CFA -XCFA,-p` gives the fragment:
{{{
    struct thing {
        struct thing()  *_X1aPS5thing_Y13__tE_generic___1;
        struct thing *_X1bPS5thing_Y13__tE_generic___1;
    };
}}}

Note the field `a` has extra parentheses (bad C syntax)
Note the field `b` is being emitted correctly

Either of the following ""workaround"" declarations (struct or function parameter) is enough, on its own, to make `thing`'s self-reference work.  The fact that a `thing(tE) *` field is valid in the workaround position suggests that self-reference is an essential part of the problem.

Working theory: the compile unit's first reference to a type cannot be a self reference.

{{{
    forall( tE & ) {
        struct thing;
        struct workaround_t {
            thing(tE) * x;
        };
        void * workaround( thing(tE) * );  // never defined
        struct thing{
            thing(tE) *a;
            thing(tE) *b;
        };
    }
}}}
"	defect	closed	minor	cfa-cc	1.0	fixed	polymorphism pointer struct	
