Undefined behaviour, in all 3 cases. That 'undefined' includes the possibility that it might work. Or look like it's working. Sometimes.
You're returning a pointer to a local variable, which is allocated on the stack. That memory is no longer reserved for that variable when it goes out of scope, which will be when the function returns. Whether or not the contents get altered, and when that happens, is down to luck. As it happens in your case, you got lucky with a couple of cases, but not the other. On a different day, the compiler might have made some different choice internally, and it behaves differently. Or maybe (probably) that data gets overwritten the next time you sneeze.
Don't do it.