https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71579

--- Comment #20 from Jonathan Wakely <redi at gcc dot gnu.org> ---
  template<typename _Tp>
    struct is_standard_layout
    : public integral_constant<bool, __is_standard_layout(_Tp)>
    {
      static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
        "template argument must be a complete class or an unbounded array");
    };

This check is wrong. It passes for Incomplete[] but that's not valid for the
trait. The precondition is: "remove_all_extents_t<T> shall be a complete type
or cv void."

The __is_standard_layout built-in gets it right:

/usr/include/c++/12/type_traits:743:38: error: invalid use of incomplete type
‘class Incomplete’

We have the same problem for is_trivial, is_trivially_copyable, is_pod,
is_literal_type.

I think we should remove the checks from those traits and just rely on the
compiler to diagnose it.

Maybe we should consider dropping all the static assertions from traits that
are implemented using a compiler built-in. The __is_constructible(T, Args...)
built-in already checks the precondition, so we're just doing unnecessary work
to repeat that check using __is_complete_or_unbounded.

Reply via email to