Doesn't the box explain the problem?
max (max(a,b), c)
in this case returns const char*
by value, which a temporary. You then return a reference to it, and the temporary dies right after returning from the function.