View Single Post
Old 18 December 2019, 18:13   #5
a/b
Registered User

 
Join Date: Jun 2016
Location: europe
Posts: 174
Yeah, it's legal. It's the same as:
Code:
char* x = NULL;
if (...) {
  x = "whatever";
}
y(x);
The value you assign is anonymous static const, it's fully known at compile time, and it's not placed on stack. It's either placed in the object's data segment and then merged with others by linker (subject to segment manipulation directives), or embedded into code e.g if it fits in 32 bits and some optimizations take place. More or less, but in any case it's safe, in c99 or any other version.
a/b is offline  
 
Page generated in 0.05401 seconds with 11 queries