c - Unsigned int field of struct got automatically initialized? -
Does C guarantee that an unsigned integer area inside a structure is started at zero? In my system, it seems (or I'm very "lucky" (actually unlucky).)
In code words, what will happen in the following scenario?
structure node {unsigned int rec_size; }; Structure node node; // what is the value of node .rec_size? Undefined or 0?
Relevant, but not so, because in my example, there is only one field and there is no initialization.
The answer depends on the storage category:
If it is < Code> _Thread_local or If it is 10 If the time of automatic storage has not been explicitly started in an object, its value is uncertain if an object that contains constant If the thread is a storage period then it is not explicitly started, then: BTW: Zero-initialize in C ++ is equal to those rules for stable / thread-local objects. is static
auto
or dynamic storage, then no one starts.
6.7.9 Initialization
Comments
Post a Comment