Yes. Your intuition is correct. Result in Matlab 2017b:
1. cd /dir/without/foo.m (actually foo.m does not yet exist)
2. fh = @foo %% no foo.m in current dir or loadpath
fh =
function_handle with value:
@foo
3. fh () %% presumably an error
Undefined function or variable 'foo'.
4. cd /dir/with/foo.m (I create foo.m in current folder)
5. fh () %% calls function defined in /dir/with/foo.m?
this is function fh (just a dummy function that displays this msg)
6. cd /dir/without/foo.m
7. fh () %% error or calls previous foo.m?
'foo' is not found in the current folder or on the MATLAB path, but exists in:
foopath
Change the MATLAB current folder or add its folder to the MATLAB path.

What does Matlab actually do with a handle to a nonexistent function? Is it possible for the handle to become valid, for example if you cd to a directory where the named function exists? Once it is valid, does it stay defined the same way as a function handle that is valid when it is created? For example, what does Matlab do for this:
If the last line is an error, then I guess a function handle to a n initially nonexistent function behaves more or less like an alias?

I would encourage you to please reconsider... It may be a Matlab bug, depending how you feel about it, but please note that it can certainly affect negatively to Octave users (http://savannah.gnu.org/bugs/?53363):
If a matlab user saves one of those function handles in a mat file together with other relevant data, an octave user will not be able to access that data because octave fails to load the mat file due to this problem with function handles.

See also bug #31821

@Johannes:
Apologies for appearing a bit strict :) that wasn't my intention.
I can clearly perceive the usefulness of lazy evaluation by str2func in other cases as well.
However, as the thread in comment #3 shows, this soon gets one in a morass of arbitrary choices, inconsistencies and completely undocumented Matlab behavior.
For the time being I'll just lower priority & severity; perhaps one of the core devs wants to close it as "won't fix".

@Philip I simply wanted to point out the incompatibility. I find Octave's behavior fully reasonable (if properly documented). Problems like the one I mentioned happen usually only in pathological cases where something else in the code should be handled differently. In my case, the problem occurred with the thirdparty package Dynare. But I guess its problematic code will soon change, because there is no reason to create the function handle if the function does not exist (https://github.com/DynareTeam/dynare/pull/1572).

I intentionally didn't write it in comment #1 but now that Markus revealed this was discussed before I'll do mention:
Note that this is undocumented Matlab behavior (although less clearcut). The Matlab docs only mention variable names (+ of course anonymous functions, function names, etc.), but definitely not arbitrary strings.
@Johannes I feel with you, but Octave developers would have a hard time making Octave accept all sloppy Matlab code out there that yet runs fine in Matlab.
OTOH for this specific case, somewhere in the thread dug up by Markus the suggestion was made to just defer parsing str2func's input arg until the handle is really invoked. Maybe that can be acceptable for Octave in the future.
BTW what Matlab package do you refer to? supplied by TMW itself, or by a third party?

I think that issue was discussed here [1].
If I am correctly reading what jwe wrote, he doesn't like the way Matlab handles "lazy" function handle evaluation. That probably means that it is unlikely that Octave will adopt it in the future.
I didn't find another bug report about that particular issue. So I'll keep this one open.
[1] http://octave.1599824.n4.nabble.com/Functionhandlesfornonexistingfunctionstd1654944.html

Thanks for looking into this. My problem is that the check in Octave is stricter than Matlab's, making existing Matlab code incompatible with Octave.
Matlab will of course crash once you invoke the handle to a nonexisting function. But I use a Matlab package that creates a handle from an arbitrary string, but does not actually invoke the handle if the function specified by the string does not (yet) exist. Of course this is not optimal, but Matlab has no problem with this sequence of events.
I would simply like Octave to maintain Matlab compatibility, i.e. have str2func return a handle and only throw an error once the handle to something not existing is invoked.

The bug report title doesn't reflect what you write.
AFAIU you mention in the report that Octave's str2func() doesn't want to accept just any string; the title suggests that the input string needs to be the name of an .m file (in Octave's search path I assume).
Anyway, reading up on the Matlab docs, it looks like Matlab should behave the same as Octave, insofar that Matlab also accepts names of variables in the workspace; but once invoked the function handle referred to by str2func's output errors out. Seems fair enough.
So:
 What exactly do you want to do with the result of your example, 'str2func(["test string"])' ?
 What does Matlab do when you invoke the function handle from that example?
Apart from the fact that Octave's input check is a little more strict, it seems to me that Octave's behavior is perfectly reasonable.
OS>Any
Release> dev
Status> need info

Matlab allows to use str2func on any string. Octave in contrast throws an error if the resulting function handle does not link to an existing function.
results in
while Matlab outputs a function handle
