In short, the problem appears to be this code in fold_builtin_memcmp:
/* If len parameter is one, return an expression corresponding to
(*(const unsigned char*)arg1 - (const unsigned char*)arg2). */
if (host_integerp (len, 1) && tree_low_cst (len, 1) == 1)
{
tree cst_uchar_node = build_type_variant (unsigned_char_type_node, 1, 0);
tree cst_uchar_ptr_node = build_pointer_type (cst_uchar_node);
Any suggestions how to fix this?
Maybe change the above to
build_pointer_type_for_mode (cst_uchar_node, ptr_mode, true)