This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [RFC PATCH] -Wmemset-transposed-args (PR middle-end/61294)
- From: Jason Merrill <jason at redhat dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>, "Carlos O'Donell" <carlos at redhat dot com>, Siddhesh Poyarekar <siddhesh at redhat dot com>, gcc-patches at gcc dot gnu dot org, libc-alpha at sourceware dot org
- Date: Tue, 08 Jul 2014 15:33:50 -0700
- Subject: Re: [RFC PATCH] -Wmemset-transposed-args (PR middle-end/61294)
- Authentication-results: sourceware.org; auth=none
- References: <20140708125017 dot GN31640 at tucnak dot redhat dot com> <p35hitgbscyj3xuum5kryq1g dot 1404847489032 at email dot android dot com> <20140708203151 dot GP31640 at tucnak dot redhat dot com>
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 07/08/2014 01:31 PM, Jakub Jelinek wrote:
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'.
Right, I consider '\0' to be a literal 0.
But in the C++ FE there isn't something like that. Do you think we
shouldn't warn even if e.g. the last argument is a template parameter
that turns out to be 0, so warn only during parsing and check for literal
0 and not warn again during instantiation?
Yes, that's what I think.
Any suggestions how to find out
if it was literal 0 or something that folded to 0 in the C++ FE?
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.
Jason