在linux上,使用gcc 4.8.4,使用-std = c ++ 11 -mcx16编译:
#include <atomic>
struct node_t;
struct pointer_t {
node_t* ptr;
unsigned int count;
pointer_t() noexcept : ptr{nullptr}, count{0} {}
};
struct empty {};
struct node_t {
empty value;
std::atomic<pointer_t> next;
node_t() : next{pointer_t{}} {}
};
int main() {
node_t{}.next.load();
return 0;
}
在调用load
时给出段错误。我打算如何初始化原子值?