From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] master 6cd5678: Clarify compiler-pacifier in frame.c Date: Tue, 27 Aug 2019 05:05:33 -0700 Organization: UCLA Computer Science Department Message-ID: <632b7c28-63d2-d400-bfff-096258d76d9a@cs.ucla.edu> References: <835zmnjdjm.fsf@gnu.org> <227db16b-17d1-b44b-97b3-e80211415eef@cs.ucla.edu> <831rx9iupo.fsf@gnu.org> <32f9db09-0c04-df03-4bb7-76fe2aa9a88f@cs.ucla.edu> <83tva4fjkz.fsf@gnu.org> <87cb5a0c-bdd8-726c-80ed-92e9f3518a58@cs.ucla.edu> <83o90cfecf.fsf@gnu.org> <87lfvg3qbi.fsf@telefonica.net> <83imqjgb1g.fsf@gnu.org> <87ftln4wm0.fsf@telefonica.net> <83a7bvg4a2.fsf@gnu.org> <87blwb4u2i.fsf@telefonica.net> <835zmjg1re.fsf@gnu.org> <831rx7f863.fsf@gnu.org> <834b9308-5235-be47-1cf8-136bb6f35e48@cs.ucla.edu> <83lfvfdoj6.fsf@gnu.org> <9d22dab3-e353-2401-0de3-6fc149e9e09f@cs.ucla.edu> <83ftlmewy7.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------E6F3F8B5F580EC14050326CB" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="61222"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Aug 27 14:08:07 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i2aGc-000FdP-Kv for ged-emacs-devel@m.gmane.org; Tue, 27 Aug 2019 14:08:06 +0200 Original-Received: from localhost ([::1]:50458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2aGa-0005Mf-LQ for ged-emacs-devel@m.gmane.org; Tue, 27 Aug 2019 08:08:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46775) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2aEH-0004o0-7w for emacs-devel@gnu.org; Tue, 27 Aug 2019 08:05:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2aEF-0004Wa-7C for emacs-devel@gnu.org; Tue, 27 Aug 2019 08:05:40 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:36624) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i2aEC-0004VA-Vb; Tue, 27 Aug 2019 08:05:37 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id BFD871600E6; Tue, 27 Aug 2019 05:05:34 -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 LWM9qYVl4O-S; Tue, 27 Aug 2019 05:05:33 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id B51771600EC; Tue, 27 Aug 2019 05:05:33 -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 OsrLlk8pkLJV; Tue, 27 Aug 2019 05:05:33 -0700 (PDT) Original-Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 886DD1600E6; Tue, 27 Aug 2019 05:05:33 -0700 (PDT) In-Reply-To: <83ftlmewy7.fsf@gnu.org> Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 131.179.128.68 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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:239616 Archived-At: This is a multi-part message in MIME format. --------------E6F3F8B5F580EC14050326CB Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Eli Zaretskii wrote: > Do you have a guess why GCC might get lost in that code? Sure, lots of guesses. GCC may have a limit on how many variables it's willing to analyze before it gives up. Or maybe it has a limit on the complexity of the mask being used. Or maybe it's just using range and oddity analyses and that works only up to two-bit masks. (I should say that GCC is "lost" only in the sense that it's issuing bogus warnings; it's still generating correct code.) To illustrate, please see the attached file maybe-uninitialized.c. When I compile it with 'gcc -O2 -Wmaybe-uninitialized -S maybe-uninitialized.c' on Fedora 30 x86-64, GCC warns that w, x, and y might be used uninitialized in bar4. It doesn't warn about h in bar4 even though h is initialized using the same strategy as the others. GCC also doesn't warn about bar2's locals even though bar 2 uses the same strategy as bar4. All the warnings GCC issues are false alarms, and these false alarms come from bar4 (with 4 variables) rather than from bar2 (with only 2). >>> And how should GCC know that? >> >> GCC could use the same sort of reasoning I used. > > Which reasoning is that? You haven't presented your reasoning for > XParseGeometry, AFAICT. You presented reasoning for some other code, > which you consider similar. I presented the reasoning GCC's bogus warning about XParseGeometry's caller in this earlier email: https://lists.gnu.org/r/emacs-devel/2019-08/msg00531.html If that presentation wasn't clear enough I can go into it in more detail; just let me know which parts weren't clear. Perhaps maybe-uninitialized.c will help explain things too. > UNINIT is for you to be able to use your tools of choice, and > perhaps also to cater to your personal stylistic preferences. It's not just me using those tools. And UNINIT is not my stylistic preference: I don't like using UNINIT and when variables need not be initialized I'd rather just not initialize them (this is the longstanding tradition in GNU and UNIX code). The only reason for UNINIT is that it's more useful for preventing and catching bugs than its alternatives are. --------------E6F3F8B5F580EC14050326CB Content-Type: text/x-csrc; name="maybe-uninitialized.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="maybe-uninitialized.c" extern int v; extern int bar2 (void); extern int bar4 (void); int v; static int foo2 (int *x, int *y) { int mask = 0; if (v & 1) { mask = 1; *x = v; } if (v & 2) { mask |= 2; *y = v; } return mask; } int bar2 (void) { int sum = 0; int x, y; int mask = foo2 (&x, &y); if (mask & 1) sum += x; if (mask & 2) sum += y; return sum; } static int foo4 (int *x, int *y, int *w, int *h) { int mask = 0; if (v & 1) { mask = 1; *x = v; } if (v & 2) { mask |= 2; *y = v; } if (v & 4) { mask |= 4; *w = v; } if (v & 8) { mask |= 8; *h = v; } return mask; } int bar4 (void) { int sum = 0; int x, y, w, h; int mask = foo4 (&x, &y, &w, &h); if (mask & 1) sum += x; if (mask & 2) sum += y; if (mask & 4) sum += w; if (mask & 8) sum += h; return sum; } --------------E6F3F8B5F580EC14050326CB--