On Fri, Aug 24, 2018 at 12:16 AM Martin Sebor <mse...@gmail.com> wrote: > > PR 87059 - internal compiler error: in set_value_range, at > tree-vrp.c:289, is apparently due to an argument type mismatch > in a MIN_EXPR introduced by expand_builtin_strncmp(). > > The function calls c_strlen() to compute the length of the two > string arguments to strncmp() and then replaces the third (bound) > argument with a MIN (len, bound). The type mismatch is caused by > len being the signed result of c_strlen(), while bound being > the size_t argument (explicitly converted to sizetype by > the function). > > My question is: why does c_strlen() return a ssizetype, a signed > type, rather the more natural sizetype? I ask in part because > changing expand_builtin_strncmp() to convert the bound to > ssizetype has downstream effects in the test suite, in part > because it seems unexpected for the function to return a signed > type given that the result cannot be negative, and in part also > because I see most callers explicitly convert the result to > size_type_node.
You have to dig into history youself but yes, it doesn't make much sense. Possibly to avoid negative values to overflow to large positive ones? Richard. > Thanks > Martin