On Wed, Jul 9, 2014 at 12:33 AM, Jason Merrill <[email protected]> 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 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.
Ick. (please no - at least make sure it doesn't survive anywhere to the middle-end, like fold or gimple). Richard. > Jason >
