Opened 7 months ago
Last modified 6 months ago
#304 closed defect
Polymorphic self reference does not work — at Initial Version
Reported by: | mlbrooks | Owned by: | |
---|---|---|---|
Priority: | minor | Component: | cfa-cc |
Version: | 1.0 | Keywords: | polymorphism pointer struct |
Cc: |
Description
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
The following convoluted sequence of declarations gives a workaround:
struct nothing {}; forall( tE & ) { struct nothing_poly {}; struct thing; extern "C" { nothing xx(nothing_poly(tE)*); // never defined foo(thing(tE)) * not_a_literal(); // never defined } struct thing{ typeof(xx(not_a_literal())) shouldBeHarmless; thing(tE) *a; thing(tE) *b; }; }
Note:
See TracTickets
for help on using tickets.