]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: ICE with ptr-to-member-fn [PR119344]
authorMarek Polacek <polacek@redhat.com>
Mon, 17 Mar 2025 21:46:02 +0000 (17:46 -0400)
committerMarek Polacek <polacek@redhat.com>
Tue, 18 Mar 2025 20:32:26 +0000 (16:32 -0400)
commit6fc1f70f0b7b50fd85aa58a0f29dd1e17f2113d1
tree508cd281db5f09f0779c8105430e9ee1f821112f
parent145c90720640ec6711ed3e5aa4152bbe1ee21751
c++: ICE with ptr-to-member-fn [PR119344]

This ICE appeared with the removal of NON_DEPENDENT_EXPR.  Previously
skip_simple_arithmetic would get NON_DEPENDENT_EXPR<CAST_EXPR<>> and
since NON_DEPENDENT_EXPR is neither BINARY_CLASS_P nor UNARY_CLASS_P,
there was no problem.  But now we pass just CAST_EXPR<> and a CAST_EXPR
is a tcc_unary, so we extract its null operand and crash.

skip_simple_arithmetic is called from save_expr.  cp_save_expr already
avoids calling save_expr in a template, so that seems like an appropriate
way to fix this.

PR c++/119344

gcc/cp/ChangeLog:

* typeck.cc (cp_build_binary_op): Use cp_save_expr instead of save_expr.

gcc/testsuite/ChangeLog:

* g++.dg/conversion/ptrmem10.C: New test.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/typeck.cc
gcc/testsuite/g++.dg/conversion/ptrmem10.C [new file with mode: 0644]