Subject: bug#38691: CC Mode 5.34 (C++//lhw); `Invalid search bound` when undo

From: "Sun, Wei" <[email-masked]>
Date: Fri, 20 Dec 2019 10:13:32 +0000

Package: cc-mode

$> cat test.cpp
// 2019-12-20 17:57

emacs -Q test.cpp

M-x mark-page RET
C-u M-x shell-command-on-region RET
sort RET
M-x undo RET

Debugger entered--Lisp error: (error "Invalid search bound (wrong side of point)")
  search-forward-regexp("R\"\\([^ ()\\\n\15\11]\\{0,16\\}\\)(" -20 bound)
  c-after-change-unmark-raw-strings(1 1 21)
  #f(compiled-function (fn) #<bytecode 0x91e275>)(c-after-change-unmark-raw-strings)
  mapc(#f(compiled-function (fn) #<bytecode 0x91e275>) (c-depropertize-new-text c-after-change-escape-NL-in-string c-after-change-unmark-raw-strings c-parse-quotes-after-change c-after-change-mark-abnormal-strings c-extend-font-lock-region-for-macros c-neutralize-syntax-in-CPP c-restore-<>-properties c-change-expand-fl-region))
  c-after-change(1 1 21)
  primitive-undo(1 ((1 . 22) (#("// 2019-12-20 17:57\n\n" 0 1 (face font-lock-comment-delimiter-face c-is-sws t c-in-sws t fontified t) 1 3 (face font-lock-comment-delimiter-face c-in-sws t fontified t) 3 20 (face font-lock-comment-face c-in-sws t fontified t) 20 21 (fontified t c-is-sws t)) . 1) (#<marker at 1 in test.cpp> . -21) (#<marker in no buffer> . -21) (#<marker at 1 in test.cpp> . -21) (t 24060 40235 192206 220000) nil (#("-" 0 1 (fontified t)) . 1) nil (#("#include <test.hpp>" 0 1 (face font-lock-preprocessor-face c-is-sws t c-in-sws t fontified t) 1 8 (face font-lock-preprocessor-face c-in-sws t fontified t) 8 9 (c-in-sws t fontified t) 9 10 (category c-<-as-paren-syntax face font-lock-string-face c-in-sws t fontified t) 10 18 (face font-lock-string-face c-in-sws t fontified t) 18 19 (category c->-as-paren-syntax face font-lock-string-face c-in-sws t fontified t)) . 22) (t 24060 40193 724383 390000)))
  undo-more(1)
  undo(nil)
  funcall-interactively(undo nil)
  call-interactively(undo nil nil)
  command-execute(undo)

Package: cc-mode

Emacs  : GNU Emacs 27.0.50 (build 6, x86_64-pc-linux-gnu, GTK+ Version 3.18.9)
 of 2019-12-20
Package: CC Mode 5.34 (C++//lhw)
Buffer Style: google
c-emacs-features: (pps-extended-state col-0-paren posix-char-classes gen-string-delim gen-comment-delim syntax-properties 1-bit)

current state:
==============
(setq
 c-basic-offset 4
 c-comment-only-line-offset 0
 c-indent-comment-alist '((other space . 2))
 c-indent-comments-syntactically-p t
 c-block-comment-prefix "* "
 c-comment-prefix-regexp '((pike-mode . "//+!?\\|\\**") (awk-mode . "#+") (other . "//+\\|\\**"))
 c-doc-comment-style '((java-mode . javadoc) (pike-mode . autodoc) (c-mode . gtkdoc) (c++-mode . gtkdoc))
 c-cleanup-list '(brace-else-brace brace-elseif-brace brace-catch-brace empty-defun-braces defun-close-semi list-close-comma scope-operator)
 c-hanging-braces-alist '((defun-open after) (defun-close before after) (class-open after) (class-close before after) (inexpr-class-open after) (inexpr-class-close before) (namespace-open after) (inline-open after) (inline-close before after)
                          (block-open after) (block-close . c-snug-do-while) (extern-lang-open after) (extern-lang-close after) (statement-case-open after) (substatement-open after))
 c-hanging-colons-alist '((case-label) (label after) (access-label after) (member-init-intro before) (inher-intro))
 c-hanging-semi&comma-criteria '(c-semi&comma-no-newlines-for-oneline-inliners c-semi&comma-inside-parenlist c-semi&comma-no-newlines-before-nonblanks)
 c-backslash-column 48
 c-backslash-max-column 72
 c-special-indent-hook nil
 c-label-minimum-indentation 1
 c-offsets-alist '((inexpr-class . +)
                   (inexpr-statement . +)
                   (lambda-intro-cont . +)
                   (inlambda . 0)
                   (template-args-cont c-lineup-template-args +)
                   (incomposition . +)
                   (inmodule . +)
                   (innamespace . 0)
                   (inextern-lang . +)
                   (composition-close . 0)
                   (module-close . 0)
                   (namespace-close . 0)
                   (extern-lang-close . 0)
                   (composition-open . 0)
                   (module-open . 0)
                   (namespace-open . 0)
                   (extern-lang-open . 0)
                   (objc-method-call-cont c-lineup-ObjC-method-call-colons c-lineup-ObjC-method-call +)
                   (objc-method-args-cont . c-lineup-ObjC-method-args)
                   (objc-method-intro . [0])
                   (friend . 0)
                   (cpp-define-intro c-lineup-cpp-define +)
                   (cpp-macro-cont . +)
                   (cpp-macro . [0])
                   (inclass . +)
                   (stream-op . c-lineup-streamop)
                   (arglist-cont-nonempty c-lineup-gcc-asm-reg c-lineup-arglist)
                   (arglist-cont c-lineup-gcc-asm-reg 0)
                   (comment-intro . 0)
                   (catch-clause . 0)
                   (else-clause . 0)
                   (do-while-closure . 0)
                   (access-label . /)
                   (substatement . +)
                   (statement-case-intro . +)
                   (statement . 0)
                   (brace-entry-open . 0)
                   (brace-list-entry . 0)
                   (brace-list-close . 0)
                   (block-close . 0)
                   (block-open . 0)
                   (inher-cont . c-lineup-multi-inher)
                   (inher-intro . ++)
                   (member-init-cont . c-lineup-multi-inher)
                   (member-init-intro . ++)
                   (annotation-var-cont . +)
                   (annotation-top-cont . 0)
                   (topmost-intro . 0)
                   (knr-argdecl . 0)
                   (func-decl-cont . ++)
                   (inline-close . 0)
                   (class-close . 0)
                   (class-open . 0)
                   (defun-block-intro . +)
                   (defun-close . 0)
                   (defun-open . 0)
                   (c . c-lineup-C-comments)
                   (string . c-lineup-dont-change)
                   (topmost-intro-cont . c-lineup-topmost-intro-cont)
                   (brace-list-intro . +)
                   (brace-list-open . 0)
                   (inline-open . 0)
                   (arglist-close . c-lineup-arglist)
                   (arglist-intro google-c-lineup-expression-plus-4)
                   (statement-cont nil c-lineup-assignments ++)
                   (statement-case-open . +)
                   (label . /)
                   (substatement-label . 2)
                   (substatement-open . 0)
                   (knr-argdecl-intro . +)
                   (statement-block-intro . +)
                   (case-label . +)
                   )
 c-buffer-is-cc-mode 'c++-mode
 c-tab-always-indent t
 c-syntactic-indentation t
 c-syntactic-indentation-in-macros t
 c-ignore-auto-fill '(string cpp code)
 c-auto-align-backslashes t
 c-backspace-function 'backward-delete-char-untabify
 c-delete-function 'delete-char
 c-electric-pound-behavior nil
 c-default-style '((java-mode . "java") (awk-mode . "awk") (other . "gnu"))
 c-enable-xemacs-performance-kludge-p t
 c-old-style-variable-behavior nil
 defun-prompt-regexp nil
 tab-width 4
 comment-column 40
 parse-sexp-ignore-comments t
 parse-sexp-lookup-properties t
 auto-fill-function nil
 comment-multi-line t
 comment-start-skip "\\(//+\\|/\\*+\\)\\s *"
 fill-prefix nil
 fill-column 80
 paragraph-start "[ 	]*\\(//+\\|\\**\\)[ 	]*$\\|^\f"
 adaptive-fill-mode t
 adaptive-fill-regexp "[ 	]*\\(//+\\|\\**\\)[ 	]*\\([ 	]+\\|[ 	]*\\([0-9]+\\.\\|\\*+\\)[ 	]*\\)"
 )