c++ - Is a local scoped variable initialized to an undetermined value, or un-initialized? -
pedantically speaking, x initialized in following code or not?
int main() { int x; } there paragraphs in 8.5 initializers [dcl.init] (for c++11) not backed examples.
it formally default-initialized, means ints, no initialization performed.
[dcl.init]/12 (n3797)
if no initializer specified object, object default-initialized; if no initialization performed, object automatic or dynamic storage duration has indeterminate value
[dcl.init]/7
to default-initialize object of type
tmeans:
if
t(possibly cv-qualified) class type, default constructortcalled [...];if
tarray type, each element default-initialized;otherwise, no initialization performed.
Comments
Post a Comment