[PATCH] D42498: [ExprConstant] Fix crash when initialize an indirect field with another field.
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 23 15:11:01 PST 2018
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.
Looks good, thanks!
In https://reviews.llvm.org/D42498#1015419, @vsapsai wrote:
> In https://reviews.llvm.org/D42498#1007028, @rsmith wrote:
>
> > […] your approach will still go wrong if the `This` pointer is used in other ways, such as an explicit mention of `this` or a member function call.
>
>
> I wasn't able to find a failing test case. Maybe I misunderstood you but in my testing functions declared in named structs had correct `This` pointer and in anonymous structs functions cannot be declared.
Here's a testcase that fails today:
struct A { int n = 0; struct { void *p = this; }; void *q = this; };
constexpr A a = A();
static_assert(a.p != a.q, ""); // fails today, should pass
constexpr A b = A{0};
static_assert(b.p != b.q, ""); // passes today
With the previous approach of fixing up the `This` value only in class member access, the above testcase would presumably still fail. I expect it to pass with your new approach.
https://reviews.llvm.org/D42498
More information about the cfe-commits
mailing list