Is this code valid?
const char* foo() {
return "Hello World";
}
That is, return "Hello World" from a C function.
const char* str = foo();
Will str be a dangling pointer?
PS: The above function is abstracted from some real code. I see someone write code that returns a string literal directly.