https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92683
Bug ID: 92683 Summary: [10 Regression] strncmp incorrect result with equal substrings and non-const bound Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- r278621 introduced a bug where a non-constant bound in calls to strncmp is treated incorrectly as if it were a constant greater than the length of either argument. $ cat t.c && gcc -O1 -S -Wall -Wextra -Wunused -fdump-tree-forwprop1=/dev/stdout t.c int f (void) { return __builtin_strncmp ("123", "1234", 3); // correctly folded to zero } int g (void) { int n = 3; return __builtin_strncmp ("123", "1234", n); // incorrectly folded to -1 } ;; Function f (f, funcdef_no=0, decl_uid=1930, cgraph_uid=1, symbol_order=0) f () { <bb 2> : return 0; } ;; Function g (g, funcdef_no=1, decl_uid=1933, cgraph_uid=2, symbol_order=1) g () { int n; <bb 2> : return -1; }