[PATCH] D45898: [SemaCXX] Mark destructor as referenced

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 9 11:49:21 PST 2018


rjmccall added a comment.

In D45898#1324625 <https://reviews.llvm.org/D45898#1324625>, @orivej wrote:

> I have noticed that this change breaks seemingly valid code:
>
>   class A { protected: ~A(); };
>   struct B : A {};
>   B f() { return B(); }
>   B g() { return {}; }
>
>
> `f` compiles, but `g` fails with `temporary of type 'A' has protected destructor`. (g++ 8.2 compiles this file.)


We talked about this in the analysis for https://reviews.llvm.org/D53860, and Richard decided that it is indeed invalid under the standard.

As a language designer I'm not sure that's a good language rule, but it's the realm of a standard defect, not a compiler bug.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D45898/new/

https://reviews.llvm.org/D45898





More information about the cfe-commits mailing list