[Bug testsuite/98771] [10/11 regression] gcc.dg/strcmpopt_8.c FAILs
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Jan 22 00:30:05 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98771
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2021-01-22
Status|UNCONFIRMED |WAITING
--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
I can't reproduce these failures with my solaris2.11 cross. The dump and the
warnings indicate that it's only the strncmp calls with a bound of SIZE_MAX
that aren't folded in your environment, like this one:
void f (void)
{
if (!(0 > __builtin_strncmp ("123", "12345", __SIZE_MAX__)))
__builtin_abort (); // should be eliminated
}
All other calls, including those with SIZE_MAX - 1, are folded successfully.
The folding happens in fold_const_call() in fold-const-call.c:
case CFN_BUILT_IN_STRNCMP:
if (!host_size_t_cst_p (arg2, &s2))
return NULL_TREE;
if (s2 == 0
&& !TREE_SIDE_EFFECTS (arg0)
&& !TREE_SIDE_EFFECTS (arg1))
return build_int_cst (type, 0);
else if ((p0 = c_getstr (arg0)) && (p1 = c_getstr (arg1)))
return build_int_cst (type, strncmp (p0, p1, s2));
return NULL_TREE;
I wonder if the host_size_t_cst_p() test passes for you. If the native GCC's
size_t is a 32-bit type then that might explain why it would fail, but then I'm
not sure what lets the calls with SIZE_MAX - 1 be folded.
More information about the Gcc-bugs
mailing list