http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51744

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Mark Pizzolato from comment #7)
> Thanks for reducing this test case further.  That illuminates something for
> me:
> 
> Specifically:
> 
> Notice in the following lines:
> 
>   if (__builtin_constant_p (__len) && __len == 0
>       && (!__builtin_constant_p (__ch) || __ch != 0))
>     {
> 
> The part of the expression "|| __ch != 0)"
> 
> What could possibly be the purpose of this check?
> 
> That is exactly why the 3rd condition I previously mentioned:
> 
> > 3) memset is called with a NON zero fill value argument.
> 
> triggers this issue.  The warning is about the length, but it is checking
> the value being set.  How could that make sense?  Clearly this check lets
> the vast majority of uses of memset pass without issue since all of those
> cases use 0 as the value to be set.
> 
> From my point of view, if that check wasn't there (i.e. remove "|| __ch !=
> 0" from the expression), the problem would not exist.

When val == 0 then the case of len == 0 is ambiguous and you can't really
tell the user they swapped val and len (because they are equal).

Reply via email to