[llvm-bugs] [Bug 51054] is_trivial not always equal to is_trivially_default_constructible && is_trivially_copyable

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jul 11 18:44:50 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51054

Richard Smith <richard-llvm at metafoo.co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|NEW                         |RESOLVED

--- Comment #1 from Richard Smith <richard-llvm at metafoo.co.uk> ---
Recent Clang appears to be correct; old Clang and GCC appear to be incorrect.

For a class to be trivial, it must be trivially copyable, and all of its
(eligible) default constructors must be trivial.

In the case of S<int>, there are two default constructors:
* the defaulted S::S(), which is trivial
* the user-provided constexpr S::S(Args...), which is not trivial
So S<int> is not trivial.

However, S<int> *is* trivially default constructible, because overload
resolution for the expression S<int>() selects a trivial default constructor.

(The notion of a "trivial class" is somewhat useless, for largely this reason
-- you usually care about what overload resolution would select, not about what
constructors the class happens to declare.)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210712/a8edc6a5/attachment.html>


More information about the llvm-bugs mailing list