[Bug c++/123044] [15/16 regression] ICE: in implicit_conversion, at cp/call.cc:2236 since r15-6709
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Dec 19 11:15:00 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123044
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Jason Merrill <jason@gcc.gnu.org>:
https://gcc.gnu.org/g:93c0642bb54ee3205db666a47a06f87d6c50eff2
commit r16-6275-g93c0642bb54ee3205db666a47a06f87d6c50eff2
Author: Egas Ribeiro <egas.g.ribeiro@tecnico.ulisboa.pt>
Date: Thu Dec 11 13:30:49 2025 +0000
c++: Fix ICE with functional cast to reference in template [PR123044]
When processing a functional cast to a reference type in a template
context, build_functional_cast_1 wasn't calling convert_from_reference.
This left the expression with a reference type, which later triggered
an assertion in implicit_conversion from r15-6709 that expects
expression types to already be dereferenced.
In contrast, cp_build_c_cast already calls convert_from_reference on
the result in template contexts, so C-style casts like (R)x worked
correctly.
The fix makes functional casts consistent with C-style casts by
calling convert_from_reference before returning in the template
processing path.
PR c++/123044
gcc/cp/ChangeLog:
* typeck2.cc (build_functional_cast_1): Call convert_from_reference
on template CAST_EXPR to match C-style cast behavior.
gcc/testsuite/ChangeLog:
* g++.dg/template/implicit-func-cast.C: New test.
Signed-off-by: Egas Ribeiro <egas.g.ribeiro@tecnico.ulisboa.pt>
Reviewed-by: Jason Merrill <jason@redhat.com>
More information about the Gcc-bugs
mailing list