在Linux中,使用gcc 4.8.4,與-std = C++ 11 -mcx16編譯:std :: atomic load中的Segfault?
#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
被稱爲段錯誤。我如何初始化原子值?
就像旁註一樣,'_t'後綴是在POSIX系統上保留的。 –
我沒有看到'pointer_t :: load()'的任何聲明...... – Kevin
@BetaCarotin是的,我只是直接翻譯https://www.cs.rochester.edu/research/synchronization/pseudocode/ queues.html :) –