Subject: bug#5395: cc-mode raises on typing '>' in #include

From: Daniel Colascione <[email-masked]>
Date: Fri, 15 Jan 2010 19:17:42 -0500

Check out latest Emacs BZR.
Start with -Q
Visit an arbitrary .cpp file
Type #include <foo>

After typing the closing '>', an error is raised. Here is the traceback

Debugger entered--Lisp error: (args-out-of-range 15 16)
  remove-text-properties(15 16 (category nil))
  (let ((pos here-cpp-end)) (remove-text-properties pos (1+ pos) (quote
...)))
  (c-clear-char-property here-cpp-end (quote category))
  (progn (c-clear-char-property here-cpp-beg (quote category))
(c-clear-char-property here-cpp-end (quote category)))
  (c-clear-cpp-delimiters here-cpp-beg here-cpp-end)
  (progn (c-clear-cpp-delimiters here-cpp-beg here-cpp-end)
(c-with-cpps-commented-out (c-parse-state-1)))
  (unwind-protect (progn (c-clear-cpp-delimiters here-cpp-beg
here-cpp-end) (c-with-cpps-commented-out ...)) (and (not modified)
(buffer-modified-p) (set-buffer-modified-p nil)))
  (let* ((modified ...) (buffer-undo-list t) (inhibit-read-only t)
(inhibit-point-motion-hooks t) before-change-functions
after-change-functions deactivate-mark buffer-file-name
buffer-file-truename) (unwind-protect (progn ... ...) (and ... ... ...)))
  (c-save-buffer-state nil (c-clear-cpp-delimiters here-cpp-beg
here-cpp-end) (c-with-cpps-commented-out (c-parse-state-1)))
  (unwind-protect (c-save-buffer-state nil (c-clear-cpp-delimiters
here-cpp-beg here-cpp-end) (c-with-cpps-commented-out ...))
(c-save-buffer-state nil (c-set-cpp-delimiters here-cpp-beg here-cpp-end)))
  (c-with-all-but-one-cpps-commented-out here-cpp-beg here-cpp-end
(c-parse-state-1))
  (if (and here-cpp-beg (> here-cpp-end here-cpp-beg))
(c-with-all-but-one-cpps-commented-out here-cpp-beg here-cpp-end
(c-parse-state-1)) (c-with-cpps-commented-out (c-parse-state-1)))
  (progn (c-suppress-<->-as-parens) (if (and here-cpp-beg ...)
(c-with-all-but-one-cpps-commented-out here-cpp-beg here-cpp-end ...)
(c-with-cpps-commented-out ...)))
  (unwind-protect (progn (c-suppress-<->-as-parens) (if ... ... ...))
(c-restore-<->-as-parens))
  (c-with-<->-as-parens-suppressed (if (and here-cpp-beg ...)
(c-with-all-but-one-cpps-commented-out here-cpp-beg here-cpp-end ...)
(c-with-cpps-commented-out ...)))
  (prog1 (c-with-<->-as-parens-suppressed (if ... ... ...)) (setq
c-state-old-cpp-beg here-cpp-beg c-state-old-cpp-end here-cpp-end))
  (let (here-cpp-beg here-cpp-end) (save-excursion (when ... ... ...))
(prog1 (c-with-<->-as-parens-suppressed ...) (setq c-state-old-cpp-beg
here-cpp-beg c-state-old-cpp-end here-cpp-end)))
  c-parse-state()
  (or c-state-cache (c-parse-state))
  (c-safe-position (point) (or c-state-cache (c-parse-state)))
  (or (c-safe-position (point) (or c-state-cache ...)) 0)
  (max (or (c-safe-position ... ...) 0) (point-min))
  (setq safe-pos (max (or ... 0) (point-min)) safe-pos-list (list safe-pos))
  (if (setq safe-pos (car-safe safe-pos-list)) nil (setq safe-pos (max
... ...) safe-pos-list (list safe-pos)))
  (unless (setq safe-pos (car-safe safe-pos-list)) (setq safe-pos (max
... ...) safe-pos-list (list safe-pos)))
  (let ((pos ...) safe-pos state pps-end-pos) (while (and safe-pos-list
...) (setq safe-pos-list ...)) (unless (setq safe-pos ...) (setq
safe-pos ... safe-pos-list ...)) (while (progn ... ...) (setq safe-pos
... safe-pos-list ...)) (if (elt state 1) (setq safe-pos ...
safe-pos-list ...)) (if (or ... ...) (elt state 8)))
  (save-excursion (let (... safe-pos state pps-end-pos) (while ... ...)
(unless ... ...) (while ... ...) (if ... ...) (if ... ...)))
  c-ssb-lit-begin()
  (setq lit-beg (c-ssb-lit-begin))
  (cond ((setq lit-beg ...) (goto-char lit-beg) t) ((and paren-level
...) (if ... ... ... nil)) ((c-beginning-of-macro limit) (if ... t ...
nil)))
  (let ((pos ...) state-2 pps-end-pos) (cond (... ... t) (... ...) (...
...)))
  (and (< (skip-chars-backward skip-chars limit) 0) (let (... state-2
pps-end-pos) (cond ... ... ...)))
  (while (and (< ... 0) (let ... ...)))
  (progn (while (and ... ...)) (> (point) (progn ... ...)))
  (while (progn (while ...) (> ... ...)))
  (let ((start ...) state-2 safe-pos-list start-macro-beg lit-beg
(paren-level-pos ...)) (while (progn ... ...)) (/= (point) start))
  c-syntactic-skip-backward("^<;}" nil t)
  c-electric-lt-gt(nil)
  call-interactively(c-electric-lt-gt nil nil)

In GNU Emacs 23.1.91.1 (x86_64-apple-darwin10.2.0, NS apple-appkit-1038.25)
 of 2010-01-15 on edith.local
Windowing system distributor `Apple', version 10.3.1038
configured using `configure  '--with-ns''

Important settings:
  value of $LC_ALL: en_US.UTF-8
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: C++/l

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t
  abbrev-mode: t

Recent input:
C-x C-f <backspace> <M-backspace> <M-backspace> <M-backspace>
<M-backspace> <M-backspace> l i s <tab> <tab> <tab>
c c <tab> <backspace> <backspace> p r o <tab> g m <tab>
c c <tab> <tab> <tab> e n g <tab> <return> <escape>
x e v a l - b f <tab> <backspace> u <tab> <return>
M-x C-g C-x C-f C-a C-k / t m p / f o o . c p p <return>
# i n c l u d e SPC < f o o > <escape> x t o g g l
e d - <backspace> <backspace> - e <backspace> d e <tab>
<return> e r <tab> <return> C-a C-x k y <backspace>
<return> y e s <return> C-x C-f <up> <return> # i n
c l u d e SPC < f o o > <down-mouse-1> <mouse-1> <wheel-up>
<double-wheel-up> <triple-wheel-up> <triple-wheel-up>
<help-echo> <down-mouse-1> <mouse-1> C-x h M-w <help-echo>
<down-mouse-1> <mouse-1> q q <escape> x r e p o r t
- - e m <tab> <return>

Recent messages:
Quit
let: Args out of range: 15, 16
Making completion list...
Debug on Error enabled globally
Entering debugger...
Mark set [2 times]
Saved text until "interactively(c-electric-lt-gt nil nil)
"
Entering debugger...
Back to top level.

Load-path shadows:
None found.

Features:
(shadow sort mail-extr message sendmail ecomplete rfc822 mml mml-sec
password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231
rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc
time-date mm-util mail-prsvr gmm-utils wid-edit mailheader canlock
hashcash mail-utils emacsbug debug cus-start cus-load cc-mode cc-fonts
cc-menus cc-cmds cc-styles cc-align cc-engine cc-langs cl cl-19 cc-vars
cc-defs regexp-opt cc-bytecomp vc-dispatcher vc-bzr sha1 hex-util
help-mode view tooltip ediff-hook vc-hooks lisp-float-type mwheel ns-win
easymenu tool-bar dnd fontset image fringe lisp-mode register page
menu-bar rfn-eshadow timer select scroll-bar mldrag mouse jit-lock
font-lock syntax facemenu font-core frame cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew
greek romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button
minibuffer faces cus-face files text-properties overlay md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dbusbind ns multi-tty emacs)