all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Suboptimal bug fix in CC Mode.
Date: Mon, 15 Jan 2018 22:00:12 +0000	[thread overview]
Message-ID: <20180115220012.GA4477@ACM> (raw)

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).



             reply	other threads:[~2018-01-15 22:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-15 22:00 Alan Mackenzie [this message]
2018-01-16 17:53 ` Suboptimal bug fix in CC Mode Eli Zaretskii
2018-01-18 18:00   ` Alan Mackenzie
2018-01-23  8:50     ` John Wiegley
2018-01-21 18:37   ` Alan Mackenzie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180115220012.GA4477@ACM \
    --to=acm@muc.de \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.