]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Handle ARRAY_TYPE in check_bit_cast_type [PR114706]
authorJakub Jelinek <jakub@redhat.com>
Tue, 16 Apr 2024 07:39:19 +0000 (09:39 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 16 Apr 2024 07:39:19 +0000 (09:39 +0200)
commit79ff53453e88e40c4f2ecf6f7f7409afc41b46fc
tree224a5cc552c5c6a043356b0e718387bd59003cda
parent6e925ba0a8b9619ed789a456b087755b488d66f1
c++: Handle ARRAY_TYPE in check_bit_cast_type [PR114706]

https://eel.is/c++draft/bit.cast#3 says that std::bit_cast isn't constexpr
if To, From and the types of all subobjects have certain properties which the
check_bit_cast_type checks (such as it isn't a pointer, reference, union,
member pointer, volatile).  The function doesn't cp_walk_tree though, so
I've missed one important case, for ARRAY_TYPEs we need to recurse on the
element type.  I think we don't need to handle VECTOR_TYPEs/COMPLEX_TYPEs,
because those will not have a pointer/reference/union/member pointer in
the element type and if the element type is volatile, I think the whole
derived type is volatile as well.

2024-04-16  Jakub Jelinek  <jakub@redhat.com>

PR c++/114706
* constexpr.cc (check_bit_cast_type): Handle ARRAY_TYPE.

* g++.dg/cpp2a/bit-cast17.C: New test.
gcc/cp/constexpr.cc
gcc/testsuite/g++.dg/cpp2a/bit-cast17.C [new file with mode: 0644]