> There is another latent bug in this optimization: 'this' will have been
> converted to the base type, but we may be calling a method on a
> derived type, which will then be passed an invalid 'this' pointer.
>
> Why don't we just constrain the optimization for now to only apply
> when the static method has not been overridden in the most-derived
> type? That will catch the common case of derived->foo().
I fixed the other comments (thanks!), but I am not able to build a
testcase where this fails. What I have tried was
struct foo {
int x;
};
struct bar {
int y;
virtual int f() { return y; }
};
struct zed final : public foo, public bar {
int z;
virtual int f() {return z;}
};
int f(zed *z) {
return static_cast<bar*>(z)->f();
}
In the hope that f would call zed::f with a bar* this, but it is
correctly passing a zed*. Is this what you had in mind?
> John.
Cheers,
Rafael
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits