Subject: CC-mode infinite loop on typing < in template spec

From: Richard Copley <[email-masked]>
Date: Fri, 27 Oct 2017 08:28:18 +0100

In an empty CC-mode buffer, after typing "template <", Emacs enters an
infinite loop.

This was asked about here:
<https://emacs.stackexchange.com/questions/36423/emacs-hangs-on-c-mode-when-writting-the-character>
and reported on the emacs-devel list here:
<http://lists.gnu.org/archive/html/emacs-devel/2017-10/msg00809.html>.

Recipe:

1. Visit an empty or non-existent .cpp file
2. Type "template <". Emacs hangs.

To trigger the bug again,
3. M-x erase-buffer RET
4. M-x normal-mode RET
5. Go to step 2.

The Emacs-lisp backtrace on quit is:

Debugger entered--Lisp error: (quit)
  c-forward-<>-arglist-recur(nil)
  c-forward-<>-arglist(nil)
  c-restore-<>-properties(10 11 0)
  #f(compiled-function (fn) #<bytecode 0x22e5bad>)(c-restore-<>-properties)
  mapc(#f(compiled-function (fn) #<bytecode 0x22e5bad>)
(c-depropertize-new-text c-parse-quotes-after-change
c-extend-font-lock-region-for-macros
c-after-change-re-mark-raw-strings c-neutralize-syntax-in-and-mark-CPP
c-restore-<>-properties c-change-expand-fl-region))
  c-after-change(10 11 0)
  self-insert-command(1)
  c-electric-lt-gt(nil)
  funcall-interactively(c-electric-lt-gt nil)
  call-interactively(c-electric-lt-gt nil nil)
  command-execute(c-electric-lt-gt)

In GNU Emacs 26.0.90 (build 1, x86_64-w64-mingw32)
 of 2017-10-13 built on MACHINE
Repository revision: d79fbb1818dc442ce71e7b55a8f1a4995d6fcd9e
Windowing system distributor 'Microsoft Corp.', version 10.0.15063
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Debug on Quit enabled globally
Entering debugger...

Configured using:
 'configure --config-cache --with-modules --without-pop 'CFLAGS=-O3
 -ggdb3''

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB
TOOLKIT_SCROLL_BARS MODULES LCMS2

Important settings:
  value of $EMACSLOADPATH: c:\emacs-lisp;
  value of $LANG: en_GB.UTF-8
  locale-coding-system: cp1252

Major mode: Debugger

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny seq dired
dired-loaddefs format-spec rfc822 mml mml-sec password-cache epa derived
epg epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils help-mode
cl-print byte-opt gv bytecomp byte-compile cconv debug cus-start
cus-load cc-mode cc-fonts easymenu cc-guess cc-menus cc-cmds cc-styles
cc-align cc-engine cc-vars cc-defs cl-loaddefs cl-lib elec-pair
time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel dos-w32 ls-lisp disp-table term/w32-win w32-win
w32-vars term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite charscript charprop case-table epa-hook jka-cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote w32notify w32 lcms2 multi-tty make-network-process emacs)

Memory information:
((conses 16 125933 9286)
 (symbols 56 23532 1)
 (miscs 48 69 106)
 (strings 32 37375 1623)
 (string-bytes 1 1065619)
 (vectors 16 17502)
 (vector-slots 8 519143 6247)
 (floats 8 58 316)
 (intervals 56 311 17)
 (buffers 992 13))