> The important difference is for strn{,case}cmp folding, we pass that s2 > value as the last argument to the host functions comparing the c_getstr > results. If s2 fits into size_t, then my patch makes no difference, > but if it is larger, we know the 2 c_getstr objects need to fit into the > host address space, so larger s2 should just act essentially as strcmp > or strcasecmp; as none of those objects can occupy 100% of the address > space, using MIN (SIZE_MAX, s2) achieves that.
But SIZE_MAX is a host value, isn't it? As a matter of fact, it breaks the build with somewhat ancient glibcs: In file included from ../../src/gcc/fold-const-call.c:21: ../../src/gcc/fold-const-call.c: In function 'tree_node* fold_const_call(combined_fn, tree, tree, tree, tree)': ../../src/gcc/fold-const-call.c:1777:56: error: 'SIZE_MAX' was not declared in this scope 1777 | return build_int_cst (type, strncmp (p0, p1, MIN (s2, SIZE_MAX))); because /usr/include/stdint.h has: /* The ISO C99 standard specifies that in C++ implementations these macros should only be defined if explicitly requested. */ #if !defined __cplusplus || defined __STDC_LIMIT_MACROS -- Eric Botcazou