Re: [RFC PATCH] -Wmemset-transposed-args (PR middle-end/61294)

2014-07-09 Thread Richard Biener
On Wed, Jul 9, 2014 at 12:33 AM, Jason Merrill ja...@redhat.com wrote: On 07/08/2014 12:38 PM, Carlos O'Donell wrote: What rationale would you give for not warning on 1-1? Because it's not likely to be a case of argument transposition; it's more likely to be an expression that just happens

Re: [RFC PATCH] -Wmemset-transposed-args (PR middle-end/61294)

2014-07-09 Thread Jakub Jelinek
On Wed, Jul 09, 2014 at 12:26:09PM +0200, Richard Biener wrote: I suppose we could use an INTEGER_CST distinct from the one in TYPE_CACHED_VALUES for raw 0, with a TREE_LANG_FLAG set. Ick. (please no - at least make sure it doesn't survive anywhere to the middle-end, like fold or gimple).

Re: [RFC PATCH] -Wmemset-transposed-args (PR middle-end/61294)

2014-07-09 Thread Richard Biener
On Wed, Jul 9, 2014 at 12:32 PM, Jakub Jelinek ja...@redhat.com wrote: On Wed, Jul 09, 2014 at 12:26:09PM +0200, Richard Biener wrote: I suppose we could use an INTEGER_CST distinct from the one in TYPE_CACHED_VALUES for raw 0, with a TREE_LANG_FLAG set. Ick. (please no - at least make

Re: [RFC PATCH] -Wmemset-transposed-args (PR middle-end/61294)

2014-07-09 Thread Jakub Jelinek
On Wed, Jul 09, 2014 at 12:51:32PM +0200, Richard Biener wrote: At least it shouldn't (they are not required to be shared and usually are not if they've gone a transition from TREE_OVERFLOW to !TREE_OVERFLOW). Well, still feels ugly to me - but it's Jasons call in the end. Another

Re: [RFC PATCH] -Wmemset-transposed-args (PR middle-end/61294)

2014-07-09 Thread Manuel López-Ibáñez
All of these warnings (-Wsizeof-pointer-memaccess, -Wsizeof-array-argument and -Wmemset-transposed-args) are implemented in a hackish way, because we fold everything too early. Perhaps for such analysis we want a FOLDED_EXPR which would have arguments what it has been folded to and the

Re: [RFC PATCH] -Wmemset-transposed-args (PR middle-end/61294)

2014-07-09 Thread Jason Merrill
On 07/09/2014 10:40 AM, Manuel López-Ibáñez wrote: All of these warnings (-Wsizeof-pointer-memaccess, -Wsizeof-array-argument and -Wmemset-transposed-args) are implemented in a hackish way, because we fold everything too early. Perhaps for such analysis we want a FOLDED_EXPR which would have

RE: [RFC PATCH] -Wmemset-transposed-args (PR middle-end/61294)

2014-07-08 Thread Jason Merrill
I don't think we want to warn about e.g. 1-1, only about literal 0. Original Message From: Jakub Jelinek ja...@redhat.com Sent: Tue, Jul 8, 2014 05:50 AM To: Joseph S. Myers jos...@codesourcery.com; Jason Merrill ja...@redhat.com; Carlos O'Donell car...@redhat.com; Siddhesh

Re: [RFC PATCH] -Wmemset-transposed-args (PR middle-end/61294)

2014-07-08 Thread Carlos O'Donell
On 07/08/2014 08:50 AM, Jakub Jelinek wrote: Hi! This is an attempt to move the warning about transposed memset arguments from the glibc headers to gcc FEs. The problem with the warning in glibc is that it uses __builtin_constant_p and e.g. jump threading very often makes the warning

Re: [RFC PATCH] -Wmemset-transposed-args (PR middle-end/61294)

2014-07-08 Thread Carlos O'Donell
On 07/08/2014 03:24 PM, Jason Merrill wrote: I don't think we want to warn about e.g. 1-1, only about literal 0. What rationale would you give for not warning on 1-1? Cheers, Carlos.

Re: [RFC PATCH] -Wmemset-transposed-args (PR middle-end/61294)

2014-07-08 Thread Jakub Jelinek
On Tue, Jul 08, 2014 at 03:24:52PM -0400, Jason Merrill wrote: I don't think we want to warn about e.g. 1-1, only about literal 0. Well, at least literal 0 and '\0'. In any case, it seems both the C and C++ FEs fold the arguments too early, already during the parsing of the argument list. In

Re: [RFC PATCH] -Wmemset-transposed-args (PR middle-end/61294)

2014-07-08 Thread Jason Merrill
On 07/08/2014 12:38 PM, Carlos O'Donell wrote: What rationale would you give for not warning on 1-1? Because it's not likely to be a case of argument transposition; it's more likely to be an expression that just happens to evaluate to 0, which is fine as a length argument to memset. On