We have got customer reporting "v &obj" and "p &obj" reporting different results. Turns out it only happens for obj that is itself a reference type which "v &obj" reports the address of the reference itself instead of the target object the reference points to. This diverged from C++ semantics. This PR fixes this issue by returning the address of the dereferenced object if it is reference type. A new test is added which fails before. Co-authored-by: jeffreytan81 <jeffreytan@fb.com>
16 lines
297 B
C++
16 lines
297 B
C++
typedef int TTT;
|
|
typedef int &td_int_ref;
|
|
|
|
int main() {
|
|
int i = 0;
|
|
// references to typedefs
|
|
TTT &l_ref = i;
|
|
TTT &&r_ref = static_cast<TTT &&>(i);
|
|
// typedef of a reference
|
|
td_int_ref td_to_ref_type = i;
|
|
|
|
TTT *pl_ref = &l_ref;
|
|
TTT *pr_ref = &r_ref;
|
|
return l_ref; // break here
|
|
}
|