Subject: bug#7181: 24.0.50; args-out-of-range while reverting C++ header file. PATCH.

From: Alan Mackenzie <[email-masked]>
Date: Sun, 10 Oct 2010 14:09:58 +0000

Hi, Óscar,

On Sat, Oct 09, 2010 at 03:56:39PM +0200, Óscar Fuentes wrote:
> With the attached files the problem can be reproduced predictability:
> 
> Save the attached files b.h.master and b.h.next to a directory and cd to
> it.
> 
> $ emacs -Q &
> $ cp b.h.master b.h
> C-x C-f b.h
> $ cp b.h.next b.h
> M-x revert-buffer
> 
> and the args-out-of-range error pops:
> 
> c-clear-char-property-with-value-function: Args out of range: 166, 453
> 
> I was unable to try with the latest Emacs sources because the build is
> broken. My Emacs is from the 16 September.
> 

Please try the following patch and confirm that it works.  I'll get it
committed just as soon as I manage to connect to the new server:

*** cc-mode.el.~3~	2010-10-08 20:27:13.000000000 +0000
--- cc-mode.el	2010-10-10 13:46:28.074200752 +0000
***************
*** 1029,1038 ****
  			    (buffer-substring-no-properties type-pos term-pos)
  			    (buffer-substring-no-properties beg end)))))))
  
- 	;; (c-new-BEG c-new-END) will be the region to fontify.  It may become
- 	;; larger than (beg end).
- 	(setq c-new-BEG beg
- 	      c-new-END end)
  	(if c-get-state-before-change-functions
  	    (mapc (lambda (fn)
  		    (funcall fn beg end))
--- 1029,1034 ----
***************
*** 1086,1091 ****
--- 1082,1091 ----
  	(when c-recognize-<>-arglists
  	  (c-after-change-check-<>-operators beg end))
  
+ 	;; (c-new-BEG c-new-END) will be the region to fontify.  It may become
+ 	;; larger than (beg end).
+ 	(setq c-new-BEG beg
+ 	      c-new-END end)
  	(if c-before-font-lock-function
  	    (save-excursion
  	      (funcall c-before-font-lock-function beg end old-len)))))))

-- 
Alan Mackenzie (Nuremberg, Germany).