https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114138
--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>: https://gcc.gnu.org/g:a6a1920b592b58c38137c5c891b3bbb02b084f38 commit r14-9260-ga6a1920b592b58c38137c5c891b3bbb02b084f38 Author: Patrick Palka <ppa...@redhat.com> Date: Fri Mar 1 12:50:18 2024 -0500 c++: auto(x) partial substitution [PR110025, PR114138] In r12-6773-g09845ad7569bac we gave CTAD placeholders a level of 0 and ensured we never replaced them via tsubst. It turns out that autos representing an explicit cast need the same treatment and for the same reason: such autos appear in an expression context and so their level gets easily messed up after partial substitution, leading to premature replacement via an incidental tsubst instead of via do_auto_deduction. This patch fixes this by extending the r12-6773 approach to auto(x). PR c++/110025 PR c++/114138 gcc/cp/ChangeLog: * cp-tree.h (make_cast_auto): Declare. * parser.cc (cp_parser_functional_cast): If the type is an auto, replace it with a level-less one via make_cast_auto. * pt.cc (find_parameter_packs_r): Don't treat level-less auto as a type parameter pack. (tsubst) <case TEMPLATE_TYPE_PARM>: Generalize CTAD placeholder auto handling to all level-less autos. (make_cast_auto): Define. (do_auto_deduction): Handle replacement of a level-less auto. gcc/testsuite/ChangeLog: * g++.dg/cpp23/auto-fncast16.C: New test. * g++.dg/cpp23/auto-fncast17.C: New test. * g++.dg/cpp23/auto-fncast18.C: New test. Reviewed-by: Jason Merrill <ja...@redhat.com>