在std :: atomic load中的Segfault?

She*_*evy 7 c++ atomic segmentation-fault c++11

在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;
}
Run Code Online (Sandbox Code Playgroud)

load调用时给出段错误.我是怎么想初始化原子值的?

She*_*evy 9

事实证明这是gcc中的一个错误,已经在GCC 5.1中得到修复.指定对齐是两个单词修复它.

  • 如何指定对齐方式为两个词,举个例子?谢谢 (2认同)