[PATCH] PR libstdc++/71579 assert that type traits are not misused with an incomplete type

Jonathan Wakely jwakely@redhat.com
Wed May 8 21:10:00 GMT 2019


On 06/05/19 14:19 +0300, Antony Polukhin wrote:
>@@ -924,14 +984,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>   template<typename _Tp>
>     struct is_default_constructible
>     : public __is_default_constructible_safe<_Tp>::type
>-    { };
>+    {
>+      static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
>+	"template argument must be a complete class or an unbounded array");
>+    };
> 
>   /// is_constructible

This "///" comment is for Doxygen, and should remain with the
is_constructible trait, not __is_constructible_impl.

>-  template<typename _Tp, typename... _Args>
>-    struct is_constructible
>+    template<typename _Tp, typename... _Args>
>+    struct __is_constructible_impl
>       : public __bool_constant<__is_constructible(_Tp, _Args...)>
>     { };
> 
>+  template<typename _Tp, typename... _Args>
>+    struct is_constructible
>+      : public __is_constructible_impl<_Tp, _Args...>
>+    {
>+      static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
>+	"template argument must be a complete class or an unbounded array");
>+    };
>+
>   template<typename _Tp, bool = __is_referenceable<_Tp>::value>
>     struct __is_copy_constructible_impl;
> 

The rest looks reasonable, but I'll finish reviewing it ASAP, when I
have more time.



More information about the Libstdc++ mailing list