From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: Suspicious warning in W64 build Date: Tue, 19 Sep 2017 02:05:04 -0700 Organization: UCLA Computer Science Department Message-ID: <962d5bb4-28e1-77db-53e3-1e1aec6362fe@cs.ucla.edu> References: <1017454172.910810.1504618695244@mail.libero.it> <86a81xrndl.fsf@gmail.com> <83a81wmijy.fsf@gnu.org> <83vakkklto.fsf@gnu.org> <83poarlrcj.fsf@gnu.org> <83h8w3krx1.fsf@gnu.org> <83bmm9jt23.fsf@gnu.org> <0feb1250-beb8-5a21-0582-c879f922bb1c@cs.ucla.edu> <83zi9ti6x5.fsf@gnu.org> <84478f56-8fb2-87c3-c74c-c3ee92b6403a@cs.ucla.edu> <83tw01i0mb.fsf@gnu.org> <3bcf37e9-0028-60e9-3912-7c05d53b02f9@cs.ucla.edu> <83r2v4ivqk.fsf@gnu.org> <4492475f-b53e-1dce-81a3-cb1294506456@cs.ucla.edu> <83poaohxwj.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1505811924 6532 195.159.176.226 (19 Sep 2017 09:05:24 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 19 Sep 2017 09:05:24 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 To: Andy Moreton , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 19 11:05:19 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1duESy-0001Kk-QF for ged-emacs-devel@m.gmane.org; Tue, 19 Sep 2017 11:05:16 +0200 Original-Received: from localhost ([::1]:40897 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duET6-0006Nq-0J for ged-emacs-devel@m.gmane.org; Tue, 19 Sep 2017 05:05:24 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44991) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duESu-0006K1-KR for emacs-devel@gnu.org; Tue, 19 Sep 2017 05:05:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1duESq-0003Uc-N6 for emacs-devel@gnu.org; Tue, 19 Sep 2017 05:05:12 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:35392) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1duESq-0003TX-HY for emacs-devel@gnu.org; Tue, 19 Sep 2017 05:05:08 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id BE1F5160D8B; Tue, 19 Sep 2017 02:05:05 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id HvuTc_6MAtFI; Tue, 19 Sep 2017 02:05:05 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id F3D5C160D8C; Tue, 19 Sep 2017 02:05:04 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 2mM7e7wmysT9; Tue, 19 Sep 2017 02:05:04 -0700 (PDT) Original-Received: from [192.168.1.9] (unknown [47.154.18.85]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id D4830160D8B; Tue, 19 Sep 2017 02:05:04 -0700 (PDT) In-Reply-To: Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 131.179.128.68 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:218509 Archived-At: Andy Moreton wrote: > the whole idea of UNINIT is dubious, and invites overly clever > compilers to exploit undefined behaviour in the name of optimisation, > and emit broken code that does not meet the expectations of the > programmer. There's no such invitation, as UNINIT is used only when GCC incorrectly warns about variables being uninitialized. Although undefined behavior would occur if the variables were used before initialization, they are not used that way. Clever compilers cannot exploit undefined behavior that does not exist. These glitches arise because GCC does not warn only when it can prove that an variable will be used before being initialized (as that wouldn't be all that useful). Instead, GCC uses not-completely-reliable heuristics that sometimes result in false positives. Although GCC cannot exploit these heuristics to optimize code (because in general code optimized via unreliable heuristics might behave incorrectly), GCC can use these heuristics to generate warnings (because false-positive warnings are an acceptable price to pay if they're rare enough and if the correct warnings are useful enough). UNINIT is not the only macro used to pacify GCC, by the way. There is also CACHEABLE, and I think others. > If the compiler complains about an uninitialised use, then fix the code to > initialise the variable and remove the UB rather than disguising it with > an UNINIT macro. The code is not broken, and if "fixing" it makes it worse then we should leave it alone. The main goal here is to write clear and correct and efficient code; pacifying false positives is secondary.