Opened 7 months ago

#301 new defect

Incorrect & When Building Reference To Pointer

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

Description

If you write the following code:

void callee(int * const & value) {
    (void)value;
}

void caller() {
    int data[2] = {0, 0};
    callee(&data[0]);
}

Then you get the following error:

repro-lvalue.cfa: In function ‘_X6callerFv___1’:
repro-lvalue.cfa:10:58: error: lvalue required as unary ‘&’ operand
   10 |  callee(&data[0]);
      |

Investigating it, it does happen during the lowering from Cforall to C. As the references are replaced with pointers, the conversion from the innermost reference to a pointer conflicts with the & that is already there. The result is to address-of operators in a row, which actually works out type wise but the address-of operator isn't an lvalue and we cannot take its address. This is mixed in with (and missed by) the pass that handles lifting some expressions to temporaries so we can take their address.

This might be because of some bad/unexpected typing information or it may be adding address-of near an existing address-of was never considered.

This is a blocking issue for #133 and may be related to #282.

Change History (0)

Note: See TracTickets for help on using tickets.