Hello Alan,
Thank you for your response. Apologies for the ambiguous steps. Please find more detailed information below:
Here are the steps:
1. Open a file in c++-mode (e.g. emacs -Q test.cc).
2. Add 100 lines of some string (e.g. the word "bar" on every line for 100 lines, no quotes in the actual file):
bar
bar
bar
bar
...
bar
3. Add a unique string to line 101 (e.g. the word "foo", no quotes in the actual file).
bar
bar
bar
bar
...
bar
foo
<INCLUDE NEWLINE AT END OF FILE>
4. Close Emacs
5. Open up the file again: emacs -Q test.cc
6. Replace the unique string with some other string: M-x query-replace <RET> foo <RET> bar <RET>
7. You should hit: Args out of range: #<buffer test.cc>, 0, 1
Here's the backtrace when using debug-on-error:
Debugger entered--Lisp error: (args-out-of-range #<buffer test.cc> 0 1)
buffer-substring-no-properties(0 1)
perform-replace("foo" "a" t nil nil nil nil nil nil nil nil)
query-replace("foo" "a" nil nil nil nil nil)
funcall-interactively(query-replace "foo" "a" nil nil nil nil nil)
call-interactively(query-replace nil nil)
command-execute(query-replace)
I also wanted to add that I tried reproducing with a file that looked like the following, but did NOT see the issue then,
either with replacing "foo" (with quotes) or just foo (no quotes):
"bar"
"bar"
"bar"
...
"bar"
"foo"
Even though I'm using "emacs -Q", could it still be interacting with some of the packages I have installed?
Here's the list of packages I have installed under $HOME/.emacs.d/elpa:
avy-0.3.0
company-20181105.2312
company-lean-20171102.1454
dash-20180910.1856
dash-functional-20180107.1618
epl-20180205.2049
f-20180106.922
flycheck-20181127.1510
gnupg
go-mode-1.3.1
haskell-mode-13.16
lean-mode-20180906.1645
pkg-info-20150517.1143
rust-mode-20181008.1628
s-20180406.808