https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127134
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Andrea Pinski <[email protected]>: https://gcc.gnu.org/g:59b82e3f4f88a02158c56921effcc078ab1a5580 commit r17-3841-g59b82e3f4f88a02158c56921effcc078ab1a5580 Author: Andrea Pinski <[email protected]> Date: Tue Sep 1 14:14:50 2026 -0700 tree-eh: Fix up lhs_could_trap_p for *this [PR127133] Currently we were treating `this->a` as being non-trapping. This is ok for the rhs but on the lhs it depends on the memory was read only or not which we don't have access to right away. So right now lhs_could_trap_p would call tree_could_trap_p and then have some special cases for some read only/trapping cases. Instead let's split up tree_could_trap_p and then have the special cases directly in the new function. Bootstrapped and tested on x86_64-linux-gnu. PR tree-optimization/127133 PR tree-optimization/127134 gcc/ChangeLog: * tree-eh.cc (tree_could_trap_p): Split into ... (tree_could_trap_1): This. Take into account lhs in some cases. (lhs_could_trap_p): Just call tree_could_trap_1. gcc/testsuite/ChangeLog: * g++.dg/torture/const-method-this-1.C: New test. * g++.dg/torture/const-method-this-2.C: New test. Signed-off-by: Andrea Pinski <[email protected]>
