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

Jonathan Wakely jwakely@redhat.com
Wed Aug 19 11:29:08 GMT 2020


On 12/08/20 11:19 +0300, Antony Polukhin via Libstdc++ wrote:
>Fixed patch for type traits hardening
>
>Changelog
>
>2020-08-12  Antony Polukhin  <antoshkka@gmail.com>
>
>    PR libstdc/71579
>    * include/std/type_traits (invoke_result, is_nothrow_invocable_r)
>    Add static_asserts to make sure that the argument of the type
>    trait is not misused with incomplete types.
>    (is_swappable_with, is_nothrow_swappable_with): Add static_asserts
>    to make sure that the first and second arguments of the type trait
>    are not misused with incomplete types.
>    * testsuite/20_util/invoke_result/incomplete_neg.cc: New test.
>    * testsuite/20_util/is_nothrow_invocable/incomplete_neg.cc: New test.
>    * testsuite/20_util/is_nothrow_swappable/incomplete_neg.cc: New test.
>    * testsuite/20_util/is_nothrow_swappable_with/incomplete_neg.cc: New
>    test.
>    * testsuite/20_util/is_swappable_with/incomplete_neg.cc: New test.

Thanks, pushed to master.

Do we also want to check
(std::__is_complete_or_unbounded(__type_identity<_ArgTypes>{}) && ...)
for invoke_result and the is_invocable traits?

We can use a fold expression there, because those traits are not
defined before C++17.




More information about the Gcc-patches mailing list