https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86204
Bug ID: 86204
Summary: [9 Regression] wrong strlen result after prior strnlen
Product: gcc
Version: 8.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: ---
A bug in the strnlen() implementation committed in r261705 lets a strnlen()
result be substituted for the result of subsequent calls to strlen() with the
same argument:
$ cat c.c && gcc -O2 -Wall -Wextra -fdump-tree-optimized=/dev/stdout c.c &&
./a.out
char a[4] = "123";
int main (void)
{
unsigned n0 = __builtin_strnlen (a, 1);
unsigned n1 = __builtin_strlen (a);
if (n0 != 1 || n1 != 3)
__builtin_abort ();
}
;; Function main (main, funcdef_no=0, decl_uid=1899, cgraph_uid=1,
symbol_order=1) (executed once)
main ()
{
<bb 2> [count: 0]:
__builtin_abort ();
}
Aborted (core dumped)