Opened 18 months ago

Last modified 16 months ago

#166 assigned defect

Cannot get reference to generic member of generic struct — at Version 1

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

Description (last modified by mlbrooks)

Minimal example:

forall( dtype T )
struct a {};

struct b1 {
    a(int) aa;
};

forall( dtype T )
struct b2 {
    a(T) aa;
};

int main() {
    #ifndef THE_ERROR
    b1 thingb;
    #else
    b2(int) thingb;
    #endif

    a(int) & thinga = thingb.aa;
}

On the error, message is:

CFA Version 1.0.0 (debug)
thebug.cfa: In function ‘_X4mainFi___1’:
thebug.cfa:21:36: error: lvalue required as unary ‘&’ operand
     a(int) & thinga = thingb.aa;

Using a pointer, in place of a reference, may be a workaround. This version compiles properly:

...
int main() {
    b2(int) thingb;
    a(int) * thinga = &thingb.aa;
}

Change History (1)

comment:1 Changed 18 months ago by mlbrooks

Description: modified (diff)
Priority: majorminor
Summary: Cannot access inner member by reference when structs are genericCannot get reference to generic member of generic struct
Note: See TracTickets for help on using tickets.