"The compiler has cached the compilation environment from the last build, and with that in mind it could recompile just this one function."
First, this is actually the most trivial possible case, and even there, as you'll see, this is not correct.
Outside of a function it does not handle changing types, changing access permissions in classes, changing between virtual and non, etc.
It does not handle changing globals, things with attributes of various sorts, etc.
All of those require understanding the uses, or overestimating them.
As for whether function-local changes can have non-local effects, the answer is flatly "yes". You don't even have to be that creative, since you can do things like force template function output and other things that affect global state from a function in C++.
The assumption that because i changed text in one function, it means the possible changes are limited to that function, is not correct in C++ :)
There are languages in which it is, mind you, just C++ is 100% not one of them.
Honestly, I would strongly suggest you start to read papers on this, this is an incredibly well studied area, and the costs are well known.
If it was easy and cheap, we'd still be doing it ;)
It used to be a pretty standard feature of editing environments for things like LISP, etc.
I completely agree that doing this to live-update an optimized build would extremely expensive and difficult. And I'll happily acknowledge that (for example) adding or moving fields in a struct would be hard to implement.
But adding a compiled specialization of a template function / class should be "easy" to handle. Its non-local, but I can imagine a dependancy tree of functions needed for the compilation. On update, we can figure out a diff of that tree, free all the now-unused function bodies in the binary and then add (compiling if necessary) all the added / updated functions.
C++ might be one of the worst languages to implement this for - .NET, JVM, typescript or Go might all be much easier. But yeah, if this has been extensively looked in to I'd love to learn why we don't do it for modern development. It seems like an obvious win, and if we don't do it I hope its for good reasons.