Opened 6 years ago
Closed 2 years ago
#122 closed defect (fixed)
Reference assignment
Reported by: | pabuhr | Owned by: | |
---|---|---|---|
Priority: | major | Component: | cfa-cc |
Version: | 1.0 | Keywords: | |
Cc: |
Description
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;
Note: See
TracTickets for help on using
tickets.
Last line no longer compiles.