https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117355
--- Comment #13 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Siddhesh Poyarekar <siddh...@gcc.gnu.org>: https://gcc.gnu.org/g:684595188dea02d246edb66106d82bb7a9a22d79 commit r15-5597-g684595188dea02d246edb66106d82bb7a9a22d79 Author: Siddhesh Poyarekar <siddh...@gotplt.org> Date: Tue Nov 19 22:51:31 2024 -0500 tree-optimization/117355: object size for PHI nodes with negative offsets When the object size estimate is returned for a PHI node, it is the maximum possible value, which is fine in isolation. When combined with negative offsets however, it may sometimes end up in zero size because the resultant size was larger than the wholesize, leading size_for_offset to conclude that there's a potential underflow. Fix this by allowing a non-strict mode to size_for_offset, which conservatively returns the size (or wholesize) in case of a negative offset. gcc/ChangeLog: PR tree-optimization/117355 * tree-object-size.cc (size_for_offset): New argument STRICT, return SZ if it is set to false. (plus_stmt_object_size): Adjust call to SIZE_FOR_OFFSET. gcc/testsuite/ChangeLog: PR tree-optimization/117355 * g++.dg/ext/builtin-object-size2.C (test9): New test. (main): Call it. * gcc.dg/builtin-object-size-3.c (test10): Adjust expected size. Signed-off-by: Siddhesh Poyarekar <siddh...@gotplt.org>