From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Warnings/errors related to possibly clobbered variables Date: Tue, 13 Jan 2015 22:10:05 +0200 Message-ID: <83egqy4f36.fsf@gnu.org> References: <54B50246.2070507@yandex.ru> <54B50BC4.3060302@yandex.ru> <83k30q4pnn.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1421179826 9630 80.91.229.3 (13 Jan 2015 20:10:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 13 Jan 2015 20:10:26 +0000 (UTC) Cc: schwab@suse.de, dmantipov@yandex.ru, emacs-devel@gnu.org, eggert@cs.ucla.edu To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jan 13 21:10:20 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YB7n8-0003MM-Na for ged-emacs-devel@m.gmane.org; Tue, 13 Jan 2015 21:10:18 +0100 Original-Received: from localhost ([::1]:41218 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YB7n7-0006eN-Jg for ged-emacs-devel@m.gmane.org; Tue, 13 Jan 2015 15:10:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36715) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YB7mr-0006eC-7F for emacs-devel@gnu.org; Tue, 13 Jan 2015 15:10:02 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YB7mn-00066t-6U for emacs-devel@gnu.org; Tue, 13 Jan 2015 15:10:01 -0500 Original-Received: from mtaout24.012.net.il ([80.179.55.180]:36883) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YB7mm-00066g-Up for emacs-devel@gnu.org; Tue, 13 Jan 2015 15:09:57 -0500 Original-Received: from conversion-daemon.mtaout24.012.net.il by mtaout24.012.net.il (HyperSendmail v2007.08) id <0NI400F00STPOW00@mtaout24.012.net.il> for emacs-devel@gnu.org; Tue, 13 Jan 2015 22:01:53 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by mtaout24.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NI400401SZ57GB0@mtaout24.012.net.il>; Tue, 13 Jan 2015 22:01:53 +0200 (IST) In-reply-to: X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 80.179.55.180 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:181233 Archived-At: > From: Stefan Monnier > Cc: Dmitry Antipov , schwab@suse.de, eggert@cs.ucla.edu, emacs-devel@gnu.org > Date: Tue, 13 Jan 2015 14:43:11 -0500 > > > Why not declare the offending variables 'volatile' and forget about > > all this stuff? > > FWIW, `volatile' might not necessarily give us the behavior we > want/need. How so? Are you saying that qualifying an automatic variable as 'volatile' might change the semantics of the program? > IOW if the warning is legit, we should investigate and > decide exactly how to fix the problem (which might involve using > `volatile' or it might on the contrary involve making a copy of the > current value). > > If the warning is not legit, then it's a problem in GCC and we shouldn't > do anything on our side other than report a bug. The compiler is rarely wrong in these cases, especially if the warning comes from several different versions of it. Programs are much better than people in examining control flow. They don't understand the hidden relations between the offending variable and other conditions, so they can flag problems that don't really exist. But they rarely flag something that is clearly wrong. IME, adding 'volatile' is generally TRT in these cases. Plus, it's very simple, and goes "by the book" (a.k.a. the C Standard).