From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26260 invoked by alias); 8 Jul 2014 19:34:26 -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 26083 invoked by uid 89); 8 Jul 2014 19:34:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 08 Jul 2014 19:34:22 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s68JYHQq027452 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 8 Jul 2014 15:34:17 -0400 Received: from [10.3.113.181] (ovpn-113-181.phx2.redhat.com [10.3.113.181]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s68JYFeJ007546; Tue, 8 Jul 2014 15:34:16 -0400 Message-ID: <53BC47B7.2000704@redhat.com> Date: Tue, 08 Jul 2014 19:34:00 -0000 From: "Carlos O'Donell" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Jakub Jelinek , "Joseph S. Myers" , Jason Merrill , Siddhesh Poyarekar CC: gcc-patches@gcc.gnu.org, libc-alpha@sourceware.org Subject: Re: [RFC PATCH] -Wmemset-transposed-args (PR middle-end/61294) References: <20140708125017.GN31640@tucnak.redhat.com> In-Reply-To: <20140708125017.GN31640@tucnak.redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2014-07/txt/msg00577.txt.bz2 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 trigger even on code where it is very unlikely a user > swapped arguments. See e.g. > https://gcc.gnu.org/PR51744 > https://gcc.gnu.org/PR56977 > https://gcc.gnu.org/PR61294 > https://bugzilla.redhat.com/452219 > https://bugs.kde.org/show_bug.cgi?id=311098 > https://bugzilla.mozilla.org/show_bug.cgi?id=581227 > and many others. Thus, I'd like to warn in the FEs instead, and > once we have a GCC release with that warning in, disable the glibc > bits/string3.h: > if (__builtin_constant_p (__len) && __len == 0 > && (!__builtin_constant_p (__ch) || __ch != 0)) > { > __warn_memset_zero_len (); > return __dest; > } > warning for GCC versions with that new warning in. > > Any thoughts on this? > > If you are ok with it, either we can add it only for 4.10/5.0 and > later only, or perhaps 4.9.2 too, or even 4.9.1. For -D_FORTIFY_SOURCE=2 > built code with glibc it shouldn't make a difference (other than having > fewer false positives), but for other non-fortified -Wall compilation > it would make a difference (introducing new warnings), so perhaps > doing it only for 4.10/5.0+ is best. This seems like a sensible solution to fixing the false positives caused by jump threading (I haven't looked into that in detail, just briefly). I would prefer we enable this for 4.10/5.0+ if only to avoid the fallout (new warnings) that would happen for the distributions. We can fix the glibc header once the fix is in gcc, unless someone objects to the fix itself. Cheers, Carlos.