Opened 3 years ago

#122 new defect

Reference assignment

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


The last line compiles when the RHS type is wrong.

int i = 7;
int & r = i;
int * pi = &r;
int & r3 = &r;

The type of &r is int * allowing the assignment to pi.

In the last line, the initialization puts an implicit & before &r, so the result is address of r, which has type int &, and the assignment is allowed because the types match. But r3 must point to an int, not an int &. I have verified that r3 is pointing at r not i;

Change History (0)

Note: See TracTickets for help on using tickets.