View Single Post
Old 18 December 2019, 18:27   #7
deimos
Registered User

 
Join Date: Jul 2018
Location: France
Posts: 555
Quote:
Originally Posted by a/b View Post
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.
Right. That makes sense, I recognise those words, but it only works if it's really a constant:

Code:
    kludge = (WORD []) { x, y };
Isn't legal, right?
deimos is offline  
 
Page generated in 0.06419 seconds with 11 queries