[PATCH] [ms-cxxabi] Elide dtor access checks for pass-by-val objects in callees

Hans Wennborg hans at chromium.org
Wed Dec 18 19:22:22 PST 2013


On Wed, Dec 18, 2013 at 7:09 PM, Reid Kleckner <rnk at google.com> wrote:
> I also don't like having to emit LLVM IR for this program:
>
> class A { ~A() {} };
> struct B : A { };
> void foo(B b) { }
>
> Any call to foo would be an error, but if we just turn off the access check,
> we'll generate code for B's deleted dtor, which is really, really weird.

Yes, this is weird.

And as you pointed out, if we're compiling another TU with MSVC, that
tries to call foo(), we'll end up calling the deleted dtor that we
generated by accident :)

> On Wed, Dec 18, 2013 at 6:38 PM, David Majnemer <david.majnemer at gmail.com>
> wrote:
>>
>> I don't think we should elide these checks.  This would lead us to behave
>> differently than MSVC inside of SFINAE contexts.

Ah, didn't think about that.

I guess this means we need to keep the checks to be compatible.


I think this is enough arguments that we should keep these checks even
if they're strictly speaking rejecting some valid code.

 - Hans

>> On Wednesday, December 18, 2013, Hans Wennborg wrote:
>>>
>>>
>>>   The problem is that MarkFunctionReferenced does access checks as it
>>> marks functions as referenced. This makes perfect sense, except here when we
>>> want to be able to call the dtor but bypass the access check.
>>>
>>>   Richard: it would be interesting to hear your thoughts on this. Is the
>>> added plumbing of this boolean variable through the various functions an
>>> acceptable approach? Would it be ok to avoid that with some mechanism to
>>> "trap" access check errors (maybe a flag on Sema)? Or is it not worth the
>>> hassle to change this?
>>>
>>> http://llvm-reviews.chandlerc.com/D2409
>>> _______________________________________________
>>> cfe-commits mailing list
>>> cfe-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>



More information about the cfe-commits mailing list