[PATCH 2/3] Fold __builtin_memchr (version 2)

Martin Liška mliska@suse.cz
Mon Oct 10 10:57:00 GMT 2016

On 10/07/2016 01:21 PM, Wilco Dijkstra wrote:
> Hi,
>> -static int
>> +int
>> target_char_cast (tree cst, char *p)
>> +      if (target_char_cast (arg2, &c))
>> +	return false;
> I believe target_char_cast is incorrect if the host/target chars are not identical
> (depending on how constant strings are created there may be signed/unsigned
> mismatches too). I recently added target_char_cst_p to gimple-fold.c to avoid
> char representation mismatches, so it would be better to use that instead.
> Wilco

Thank you for the predicate, I'm going to use it.

I have one additional question whether also c_getstr should be guarded
with a similar guard? Or is it always safe to grab a char* by TREE_STRING_POINTER
and use it by a host string functions (strcmp, ...)?


More information about the Gcc-patches mailing list