> replace-regexp-in-string behaves incorrectly if a regexp has \` among
> its matches.
>
> (replace-regexp-in-string "\\`\\|X" "Z" "--XX--" t t)
> =>
> "Z--ZXZX--"
>
> where I expected
>
> "Z--ZZ--"
>
> This seems to be due to the optimization in replace-regexp-in-string
> which re-matches on the matched substring. \' can match the substring
> where it did not match in the middle of the full string. In the example
> above "X" is the match in the full string, but on taking that "X" as a
> substring it can match "\\`".
I built the emacs-25 git branch I recreated the above bug today.
GNU Emacs 25.0.92.1 (x86_64-apple-darwin13.4.0, NS appkit-1265.21 Version 10.9.5 (Build 13F1507))
of 2016-03-05