From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Suboptimal bug fix in CC Mode. Date: Mon, 15 Jan 2018 22:00:12 +0000 Message-ID: <20180115220012.GA4477@ACM> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1516053868 16254 195.159.176.226 (15 Jan 2018 22:04:28 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 15 Jan 2018 22:04:28 +0000 (UTC) User-Agent: Mutt/1.7.2 (2016-11-26) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 15 23:04:24 2018 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 1ebCrf-0003wD-FO for ged-emacs-devel@m.gmane.org; Mon, 15 Jan 2018 23:04:23 +0100 Original-Received: from localhost ([::1]:38387 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebCtf-0005rV-Et for ged-emacs-devel@m.gmane.org; Mon, 15 Jan 2018 17:06:27 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54606) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebCtU-0005pi-7l for emacs-devel@gnu.org; Mon, 15 Jan 2018 17:06:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebCtQ-0004Be-8l for emacs-devel@gnu.org; Mon, 15 Jan 2018 17:06:16 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:14391 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1ebCtQ-00048W-2O for emacs-devel@gnu.org; Mon, 15 Jan 2018 17:06:12 -0500 Original-Received: (qmail 18973 invoked by uid 3782); 15 Jan 2018 22:06:06 -0000 Original-Received: from acm.muc.de (p548C723F.dip0.t-ipconnect.de [84.140.114.63]) by colin.muc.de (tmda-ofmipd) with ESMTP; Mon, 15 Jan 2018 23:06:06 +0100 Original-Received: (qmail 6317 invoked by uid 1000); 15 Jan 2018 22:00:12 -0000 Content-Disposition: inline X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 193.149.48.1 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:221993 Archived-At: Hello, Eli. Unfortunately, a sub-optimal bug fix with unintended consequences has found its way into Emacs-26 (and master). The bug fix was a new CC Mode feature, C99 compound literals. This involves allowing brace blocks in more contexts than previously, where a brace block essentially only followed "=". The "fix" adopted was to examine the inside of "{ ... }" to determine whether it's a brace block or a statement/defun block. Essentially, a "," means brace block and ";" means statement/defun block. This strategem falls down in the following use case. Type in int main () { int a } , where the closing "}" is optional. Now type a "," after the identifier "a". CC Mode now interprets the line as a brace-block-entry, and indents it suboptimally. This indentation can need fixing by hand, after a ";" has caused the block to become a defun block. This new feature, compound literals, was requested by Nikolai Weibull in emacs-devel on 2017-08-15, and the "fix" committed by me on 2017-11-10. I became aware of the defects of this "fix" two days ago, when bug #29959 was reported by Konstantin Kharlamov. I don't think we should leave this bug in Emacs-26. Clearly, analysing the innards of "{ ... }" is not a reliable way to distinguish brace blocks from statement/defun blocks. Instead, more elaborate analysis of its context needs to be carried out. This fix will be quite involved, and will be considerably more extensive than a "one-line fix". Alternatively, the C99 compound literals feature could be removed from Emacs-26 and postponed till Emacs-27. Sorry. -- Alan Mackenzie (Nuremberg, Germany).