I find that in practice, with a variety of C++11/C++14 compilers, a std::atomic has an undefined initial value just as it would if it were a "raw" type. That is, we expect that for the expression
int a;
a may have any value. It also turns out to be true that for the expression
std::atomic< int > b;
b may also have any value. To say it another way,
std::atomic< int > b;         // b is undefined
is not equivalent to
std::atomic< int > b{ 0 };    // b == 0
or to
std::atomic< int > b{};       // b == 0
because in the latter two cases b is initialized to a known value.
My question is simple: where in the C++11 or C++14 spec is this behavior documented?
Aucun commentaire:
Enregistrer un commentaire