[llvm-bugs] [Bug 51054] New: 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 06:15:41 PDT 2021


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

            Bug ID: 51054
           Summary: is_trivial not always equal to
                    is_trivially_default_constructible &&
                    is_trivially_copyable
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: oliverzlee at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

std::is_trivial_v<T> can be false when both
std::is_trivially_default_constructible_v<T> and
std::is_trivially_copyable_v<T> are true.

-----
#include <array>
#include <type_traits>

template <class T>
struct S 
 {
  std::array<T, 3> data;

  S() = default;

  template <class... Args, class = typename std::enable_if<sizeof...(Args) ==
3>::type>
  constexpr S(Args... args) : data{args...} {}
};

static_assert(std::is_trivially_default_constructible<S<int>>::value, "");
static_assert(std::is_trivially_copyable<S<int>>::value, "");
static_assert(std::is_trivial<S<int>>::value, "");
----

Compiler explorer link: https://godbolt.org/z/Wczr1vPhb

This builds successfully with GCC and Clang 10.x and earlier with C++11/14/17.

-- 
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/20210711/1ad7ade4/attachment.html>


More information about the llvm-bugs mailing list