-
- Downloads
c++: Allow indeterminate unsigned char or std::byte in bit_cast - P1272R4
P1272R4 has added to the std::byteswap new stuff to me quite unrelated clarification for std::bit_cast. The patch treats it as DR, applying to all languages. We no longer diagnose if padding bits are stored into unsigned char or std::byte result, fields or bitfields, instead arrange for that result, those fields or bitfields to get indeterminate value (empty CONSTRUCTOR with CONSTRUCTOR_NO_ZEROING or just leaving the member's initializer out and setting CONSTRUCTOR_NO_ZEROING on parent). We still have a bug that we don't diagnose in lots of places lvalue-to-rvalue conversions of indeterminate values or class objects with some indeterminate members. 2021-12-04 Jakub Jelinek <jakub@redhat.com> * cp-tree.h (is_byte_access_type_not_plain_char): Declare. * tree.c (is_byte_access_type_not_plain_char): New function. * constexpr.c (clear_uchar_or_std_byte_in_mask): New function. (cxx_eval_bit_cast): Don't error about padding bits if target type is unsigned char or std::byte, instead return no clearing ctor. Use clear_uchar_or_std_byte_in_mask. * g++.dg/cpp2a/bit-cast11.C: New test. * g++.dg/cpp2a/bit-cast12.C: New test. * g++.dg/cpp2a/bit-cast13.C: New test. * g++.dg/cpp2a/bit-cast14.C: New test.
Showing
- gcc/cp/constexpr.c 129 additions, 2 deletionsgcc/cp/constexpr.c
- gcc/cp/cp-tree.h 1 addition, 0 deletionsgcc/cp/cp-tree.h
- gcc/cp/tree.c 12 additions, 0 deletionsgcc/cp/tree.c
- gcc/testsuite/g++.dg/cpp2a/bit-cast11.C 63 additions, 0 deletionsgcc/testsuite/g++.dg/cpp2a/bit-cast11.C
- gcc/testsuite/g++.dg/cpp2a/bit-cast12.C 68 additions, 0 deletionsgcc/testsuite/g++.dg/cpp2a/bit-cast12.C
- gcc/testsuite/g++.dg/cpp2a/bit-cast13.C 63 additions, 0 deletionsgcc/testsuite/g++.dg/cpp2a/bit-cast13.C
- gcc/testsuite/g++.dg/cpp2a/bit-cast14.C 75 additions, 0 deletionsgcc/testsuite/g++.dg/cpp2a/bit-cast14.C
Loading
Please register or sign in to comment