﻿id	summary	reporter	owner	description	type	status	priority	component	version	resolution	keywords	cc
153	Compiler error when referencing a polymorphic type from within a polymorphic method which uses a trait whose methods operate on that same polymorphic type	dkobets		"Example code:
an anonymous trait is created containing a method operating on a polymorphic type `A`, and a polymorphic method `bar` relying on this trait attempts to use `A` by instantiating it. A compiler error is generated

{{{
forall (otype T) {
    struct A {};
}

forall (otype T | {void foo(A(T));}) {
    void bar() {
        A(T) T;
    }
}

int main() {}
}}}

----

main.cfa: In function '_X3barQ1_0_0_5__X16_operator_assignFBD0_BD0BD0__X12_constructorFv_BD0__X12_constructorFv_BD0BD0__X11_destructorFv_BD0__X3fooFv_S1A_BD0___Fv___1':
main.cfa:10:46: error: '_sizeof_S1A_Y1T_' undeclared (first use in this function)
     void bar() {
                                              ^               
main.cfa:10:46: note: each undeclared identifier is reported only once for each function it appears in

----

The same compiler error is generated when the trait is not anonymous

----

Removing the requirement on `A` in the trait resolves the issue:
{{{
forall (otype T) {
    struct A {};
}

forall (otype T | {void foo(T);}) {
    void bar() {
        A(T) T;
    }
}

int main() {}
}}}


using the `-CFA` flag during compilation shows that the working version 

contains the following snippet:
{{{
unsigned long int _sizeof_S1A_Y1T_ = 1;
unsigned long int _alignof_S1A_Y1T_ = 1;
__attribute__ ((aligned(8))) char _buf22[_sizeof_S1A_Y1T_];
}}}

whereas in the broken version, the same region of code is missing the first two lines, thus resulting in an `undeclared identifier` error
{{{
__attribute__ ((aligned(8))) char _buf22[_sizeof_S1A_Y1T_];
}}}"	defect	new	minor	cfa-cc	1.0			
