[PATCH] c++, libstdc++, v2: Add __make_signed and __make_unsigned intrinsic traits
Jonathan Wakely
jwakely@redhat.com
Thu Nov 12 09:21:49 GMT 2026
On Thu, 12 Nov 2026 at 08:06, Jakub Jelinek <jakub@redhat.com> wrote:
>
> Hi!
>
> Here is an updated version of the __make_signed/__make_unsigned trait.
> Notable changes: 1) rebased on top of Arsen's quals changes
> 2) __make_unsigned_selector_base no longer defined when using compiler
> trait 3) uses __conditional_t in simd_details.h
>
> Bootstrapped/regtested on x86_64-linux and i686-linux.
>
> 2026-11-12 Jakub Jelinek <jakub@redhat.com>
>
> gcc/cp/
> * cp-trait.def (MAKE_SIGNED, MAKE_UNSIGNED): New traits.
> * semantics.cc (finish_make_signed): New function.
> (finish_trait_type): Handle CPTK_MAKE_SIGNED and CPTK_MAKE_UNSIGNED.
> * cp-tree.h (finish_make_signed): Declare.
> * reflect.cc (eval_make_signed): Use finish_make_signed.
> gcc/testsuite/
> * g++.dg/ext/has-builtin-1.C: Add __has_builtin (__make_signed)
> and __has_builtin (__make_unsigned) tests.
> * g++.dg/ext/make_signed1.C: New test.
> * g++.dg/ext/make_signed2.C: New test.
> * g++.dg/ext/make_unsigned1.C: New test.
> * g++.dg/ext/make_unsigned2.C: New test.
> libstdc++-v3/
> * include/std/type_traits (std::make_unsigned, std::make_signed): Use
> __make_unsigned and __make_signed traits if possible.
> * include/std/bit (std::byteswap): Use make_unsigned rather than
> __make_unsigned.
> * include/bits/simd_details.h (std::simd::__value_preserving_cast): Use
> __conditional_t<integral<_From>, make_unsigned<_From>,
> type_identity<_From>>::type instead of __make_unsigned<_From>::__type.
> * testsuite/24_iterators/range_access/range_access_cpp20_neg.cc: Adjust
> test for different diagnostics when using __make_signed/__make_unsigned
> traits.
> * testsuite/26_numerics/gcd/gcd_neg.cc: Likewise.
> * testsuite/26_numerics/lcm/lcm_neg.cc: Likewise.
> * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
> Likewise.
> * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Likewise.
> * testsuite/23_containers/mdspan/extents/class_mandates_neg.cc:
> Likewise.
The library parts are OK, thanks.
More information about the Libstdc++
mailing list