all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Suboptimal bug fix in CC Mode.
@ 2018-01-15 22:00 Alan Mackenzie
  2018-01-16 17:53 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Mackenzie @ 2018-01-15 22:00 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

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



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-01-23  8:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-15 22:00 Suboptimal bug fix in CC Mode Alan Mackenzie
2018-01-16 17:53 ` Eli Zaretskii
2018-01-18 18:00   ` Alan Mackenzie
2018-01-23  8:50     ` John Wiegley
2018-01-21 18:37   ` Alan Mackenzie

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.