From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10939 invoked by alias); 9 Jul 2014 10:26:17 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 10807 invoked by uid 89); 9 Jul 2014 10:26:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=unavailable version=3.3.2 X-HELO: mail-wg0-f45.google.com Received: from mail-wg0-f45.google.com (HELO mail-wg0-f45.google.com) (74.125.82.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 09 Jul 2014 10:26:15 +0000 Received: by mail-wg0-f45.google.com with SMTP id z12so5499759wgg.16 for ; Wed, 09 Jul 2014 03:26:09 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.194.104.97 with SMTP id gd1mr45123116wjb.77.1404901569237; Wed, 09 Jul 2014 03:26:09 -0700 (PDT) Received: by 10.195.11.202 with HTTP; Wed, 9 Jul 2014 03:26:09 -0700 (PDT) In-Reply-To: <53BC71CE.6000504@redhat.com> References: <20140708125017.GN31640@tucnak.redhat.com> <20140708203151.GP31640@tucnak.redhat.com> <53BC71CE.6000504@redhat.com> Date: Wed, 09 Jul 2014 10:26:00 -0000 Message-ID: Subject: Re: [RFC PATCH] -Wmemset-transposed-args (PR middle-end/61294) From: Richard Biener To: Jason Merrill Cc: Jakub Jelinek , "Joseph S. Myers" , "Carlos O'Donell" , Siddhesh Poyarekar , GCC Patches , GNU C Library Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-07/txt/msg00617.txt.bz2 On Wed, Jul 9, 2014 at 12:33 AM, Jason Merrill 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 >