https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112811
--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by David Malcolm <dmalc...@gcc.gnu.org>: https://gcc.gnu.org/g:84096e665c5f7d7ffb07f18a5fd5e804a94b237b commit r14-8256-g84096e665c5f7d7ffb07f18a5fd5e804a94b237b Author: David Malcolm <dmalc...@redhat.com> Date: Thu Jan 18 12:11:57 2024 -0500 analyzer: fix offsets in has_null_terminator [PR112811] PR analyzer/112811 reports an ICE attempting to determine whether a string is null-terminated. The root cause is confusion in the code about whether byte offsets are relative to the start of the base region, or relative to the bound fragment within the the region. This patch rewrites the code to enforce a clearer separation between the kinds of offset, fixing the ICE, and adds logging to help track down future issues in this area of the code. gcc/analyzer/ChangeLog: PR analyzer/112811 * region-model.cc (fragment::dump_to_pp): New. (fragment::has_null_terminator): Convert to... (svalue_byte_range_has_null_terminator_1): ...this new function, updating to use a byte_range relative to the start of the svalue. (svalue_byte_range_has_null_terminator): New. (fragment::string_cst_has_null_terminator): Convert to... (string_cst_has_null_terminator): ...this, updating to use a byte_range relative to the start of the svalue. (iterable_cluster::dump_to_pp): New. (region_model::scan_for_null_terminator): Add logging, moving body to... (region_model::scan_for_null_terminator_1): ...this new function, adding more logging, and updating to use svalue_byte_range_has_null_terminator. * region-model.h (region_model::scan_for_null_terminator_1): New decl. gcc/testsuite/ChangeLog: PR analyzer/112811 * c-c++-common/analyzer/strlen-pr112811.c: New test. Signed-off-by: David Malcolm <dmalc...@redhat.com>