[英]Segfault in std::atomic load?
On linux, using gcc 4.8.4, compiled with -std=c++11 -mcx16: 在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;
}
gives a segfault when load
is called. 在调用
load
时给出段错误。 How am I meant to initialize an atomic value? 我是怎么想初始化原子值的?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.