Opened 9 months ago

#282 new defect

Double Member Expressions Cannot Be Used as Lvalues

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

Description

Getting the address of a field of a field does not work:

forall( U & )
struct LinkData {
    U * top;
};

forall( S & )
struct Link {
    LinkData(S) data;
};

void g1(int*) {}
void g2(int**) {}
void g3(int*&) {}
void f(Link(int) * link)  {
    // This works:
    g1( link->data.top);
    // Assertion failure in convert.
    g2(&link->data.top);
    // Assertion failure in convert.
    g2(&(((*link).data).top));
    // This works:
    g2(&(*&(link->data)).top);
    // error: lvalue required as unary '&' operand
    g3( link->data.top);
}

I did some investigation of this error but was unable to find a solution. The error seems to occur in "Convert L-Value" particularly in reference type elimination when some references, and the implicit dereferences they imply, are removed.

Both CastExpr? and MemberExpr? don't currently track what there lvalue status would be in C, that may be related. I also have a note that FixDtypeStatic? may be related but I have since forgotten the rational for that.

Because the error message is triggered by convert, as translation continues and eventually the conversion may never need to happen, the initial error messages will probably change.

This may just be a special case of #166.

Change History (0)

Note: See TracTickets for help on using tickets.