https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87059
Aldy Hernandez <aldyh at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |msebor at gcc dot gnu.org --- Comment #6 from Aldy Hernandez <aldyh at gcc dot gnu.org> --- (tl;dr: strncmp code is creating a MIN_EXPR with incompatible types). I think my patch exposed a latent bug. Previously, the min/max code was calling int_const_binop() code, which in turns calls wide_int_binop() with the type of the first argument: int_const_binop(): ... tree type = TREE_TYPE (arg1); ... if (TREE_CODE (arg1) == INTEGER_CST && TREE_CODE (arg2) == INTEGER_CST) { wide_int warg1 = wi::to_wide (arg1), res; wide_int warg2 = wi::to_wide (arg2, TYPE_PRECISION (type)); success = wide_int_binop (res, code, warg1, warg2, sign, &overflow); poly_res = res; } But in this particular case the MIN_EXPR that was passed to VRP, and consequently int_const_binop() has incompatible argument types. Placing a breakpoint on VRP around here: else if (code == MIN_EXPR || code == MAX_EXPR) One can see that the types of vr0.min, vr1.min, and the entire MIN_EXPR (expr_type) are not entirely compatible: (gdb) p debug_generic_stmt(vr0.min.typed.type) sizetype $33 = void (gdb) p debug_generic_stmt(vr1.min.typed.type) ssizetype $34 = void (gdb) p debug_generic_stmt(expr_type) ssizetype vr0.min is unsigned, but vr1.min and the MIN_EXPR are signed. We can trace the MIN_EXPR to: expand_builtin_strncmp(): /* If we are not using the given length, we must incorporate it here. The actual new length parameter will be MIN(len,arg3) in this case. */ if (len != len3) len = fold_build2_loc (loc, MIN_EXPR, TREE_TYPE (len), len, len3); (gdb) p debug_generic_stmt(len) MIN_EXPR <(sizetype) _4, 1>; I could easily change the new VRP code to use the type of vr0 when calling wide_int_binop, fixing the PR, and keeping to the previous functionality, but I think the problem here is the incompatible MIN_EXPR. Am I missing something, or should MIN_EXPR have compatible types? Tagging Martin, since the MIN_EXPR code came from: commit 5c5d012be3c48bfcd674e4ab9d8158b171cb0e58 Author: msebor <msebor@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Wed Dec 20 16:56:20 2017 +0000 PR testsuite/83131 - c-c++/common/attr-nonstring-3 failure for strcmp tests on PowerPC gcc/ChangeLog: PR testsuite/83131 * builtins.c (expand_builtin_strlen): Use get_callee_fndecl. (expand_builtin_strcmp): Call maybe_warn_nonstring_arg. (expand_builtin_strncmp): Same.