https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125939
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Marek Polacek <[email protected]>: https://gcc.gnu.org/g:c2ea08d913db442995864b37da9900f00aa38188 commit r17-1813-gc2ea08d913db442995864b37da9900f00aa38188 Author: Marek Polacek <[email protected]> Date: Tue Jun 23 17:39:29 2026 -0400 c++/reflection: type traits and reference collapsing [PR125939] This PR shows that some of our meta type traits don't work with references: we emit bogus error: 'const' qualifiers cannot be applied to 'int&' errors. The problem is that build_stub_type is trying to add const to a reference, which you can only do through a typedef, but here we don't have a typedef. Resolved by passing tf_ignore_bad_quals to cp_build_qualified_type. The new build_const_lref helper is to spruce up the code a bit. PR c++/125939 gcc/cp/ChangeLog: * cp-tree.h (build_const_lref): Declare. * method.cc (build_stub_type): Pass tf_ignore_bad_quals to cp_build_qualified_type. * reflect.cc (build_const_lref): New. (get_range_elts): Use it. (eval_is_copy_constructible_type): Likewise. (eval_is_copy_assignable_type): Likewise. (eval_is_trivially_copy_assignable_type): Likewise. (eval_is_nothrow_copy_constructible_type): Likewise. (eval_is_nothrow_copy_assignable_type): Likewise. * tree.cc (trivially_copy_constructible_p): Likewise. (handle_annotation_attribute): Likewise. gcc/testsuite/ChangeLog: * g++.dg/reflect/type_trait15.C: New test. Reviewed-by: Jason Merrill <[email protected]>
