On Mon, Jun 22, 2015 at 2:09 PM, John McCall <[email protected]> wrote:
> Richard: this code is already testing hasTrivialDestructor. If you would
> be comfortable with declaring a trivial destructor except for performance
> reasons, maybe hasTrivialDestructor should be returning true?
I don't think that's the right place to address this: if you could somehow
get hold of the type of the anonymous union, you should find it has a
deleted destructor, and CodeGen should not even be considering making a
call to a deleted function. In fact, you can observe this:
struct A {
~A();
};
struct B {
A a;
};
struct Evil {
template<typename T> Evil(T *p) { p->~T(); }
};
struct C {
union {
B b;
Evil e = this;
};
~C() noexcept;
};
Clang (correctly, as far as I'm aware) rejects this because the anonymous
union has a deleted destructor. I think the right semantic model is that
the anonymous union field is never destroyed by the destructor of the
enclosing class.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits