On 8/11/26 12:18 PM, Jakub Jelinek wrote:
Hi!
We IMHO incorrectly leave TYPE_ALIGN of std::meta::info unset, so alignof on
it is 1. We should change that to the same as decltype (nullptr) and
void *.
As C++26 is heavily experimental, I wonder if it is fine to change it as is
or if we need to play with C++ ABI version. And whether we should change
16.3 or leave it as is (I'd say leave 16 as is).
OK for trunk as is, let's leave 16 alone.
Tested on x86_64-linux, ok for trunk?
2026-08-11 Jakub Jelinek <[email protected]>
* reflect.cc (init_reflection): Also unitialize TYPE_UNSIGNED,
TYPE_PRECISION, TYPE_MODE and TYPE_ALIGN of meta_info_type_node.
* g++.dg/reflect/info1.C: New test.
--- gcc/cp/reflect.cc.jj 2026-08-07 22:59:40.798404066 +0200
+++ gcc/cp/reflect.cc 2026-08-11 17:50:26.225408769 +0200
@@ -65,6 +65,10 @@ init_reflection ()
/* Make it a complete type. */
TYPE_SIZE (meta_info_type_node) = bitsize_int (GET_MODE_BITSIZE (ptr_mode));
TYPE_SIZE_UNIT (meta_info_type_node) = size_int (GET_MODE_SIZE (ptr_mode));
+ TYPE_UNSIGNED (meta_info_type_node) = 1;
+ TYPE_PRECISION (meta_info_type_node) = GET_MODE_BITSIZE (ptr_mode);
+ SET_TYPE_MODE (meta_info_type_node, ptr_mode);
+ SET_TYPE_ALIGN (meta_info_type_node, GET_MODE_ALIGNMENT (ptr_mode));
/* Name it. */
record_builtin_type (RID_MAX, "decltype(^^int)", meta_info_type_node);
--- gcc/testsuite/g++.dg/reflect/info1.C.jj 2026-08-11 10:19:55.315702116 +0200
+++ gcc/testsuite/g++.dg/reflect/info1.C 2026-08-11 10:19:45.631707734
+0200
@@ -0,0 +1,6 @@
+// { dg-do compile { target c++26 } }
+// { dg-additional-options "-freflection" }
+
+using info = decltype (^^::);
+static_assert (sizeof (info) == sizeof (void *));
+static_assert (alignof (info) == alignof (void *));
Jakub