]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Fix up extract_ref [PR125111]
authorJakub Jelinek <jakub@redhat.com>
Thu, 7 May 2026 06:54:21 +0000 (08:54 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 7 May 2026 06:54:21 +0000 (08:54 +0200)
commitef48b322cd98e23de57ad0d8f09ec02aa97d40c4
tree13436d2a7ba2574633eca11eed91480fc35ffda4
parent6481ee18e339356e3f5ff65428224ee4c500bc41
c++: Fix up extract_ref [PR125111]

https://eel.is/c++draft/meta.reflection.extract#5.2 requests that
is_convertible_v<remove_reference_t<U>(*)[], remove_reference_t<T>(*)[]>
is tested and if it not true, the function throws.
If U/T are references to function/method/array[], we try to build
array of types which are not valid in arrays and ICE shortly after that.
The following patch makes sure we don't create arrays in that case
and instead just throw the exception.  We can't have references to void
or references to references, so I think the other problematic cases
of creating arrays can't trigger.

2026-05-07  Jakub Jelinek  <jakub@redhat.com>

PR c++/125111
* reflect.cc (extract_ref): Throw instead of trying to build
arrays of functions, methods or arrays with NULL TYPE_DOMAIN.

* g++.dg/reflect/extract12.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/reflect.cc
gcc/testsuite/g++.dg/reflect/extract12.C [new file with mode: 0644]