Skip to content

build failure on clang 19: deleted operator '=' on atomic #2530

@katrinafyi

Description

@katrinafyi

after fixing #2529, there is another build failure with clang 19. the same failure happens on macos and linux.

souffle> /tmp/nix-build-souffle-2.4.1.drv-0/source/src/interpreter/Index.h:417:14: error: overload resolution selected deleted operator '='
souffle>   417 |         data = src.data;
souffle>       |         ~~~~ ^ ~~~~~~~~
souffle> /nix/store/cvl21fnjrwqcw59vkvhfdfl5w4d0xfaw-libcxx-19.1.6-dev/include/c++/v1/__atomic/atomic.h:58:11: note: candidate function has been explicitly deleted
souffle>    58 |   atomic& operator=(const atomic&)          = delete;
souffle>       |           ^
souffle> /nix/store/cvl21fnjrwqcw59vkvhfdfl5w4d0xfaw-libcxx-19.1.6-dev/include/c++/v1/__atomic/atomic.h:59:11: note: candidate function has been explicitly deleted
souffle>    59 |   atomic& operator=(const atomic&) volatile = delete;
souffle>       |           ^
souffle> /nix/store/cvl21fnjrwqcw59vkvhfdfl5w4d0xfaw-libcxx-19.1.6-dev/include/c++/v1/__atomic/atomic.h:49:29: note: candidate function
souffle>    49 |   _LIBCPP_HIDE_FROM_ABI _Tp operator=(_Tp __d) volatile _NOEXCEPT {
souffle>       |                             ^
souffle> /nix/store/cvl21fnjrwqcw59vkvhfdfl5w4d0xfaw-libcxx-19.1.6-dev/include/c++/v1/__atomic/atomic.h:53:29: note: candidate function
souffle>    53 |   _LIBCPP_HIDE_FROM_ABI _Tp operator=(_Tp __d) _NOEXCEPT {
souffle>       |                             ^

void insert(const Index& src) {
data = src.data;
}

it looks like the code as written wants to implicitly load/store the atomic by coercing it to a bool, but the compiler is falling back to copy assignment for atomics which is deleted. it looks like the implicit load was deprecated (removed?) in C++ 20: https://en.cppreference.com/w/cpp/atomic/atomic/operator_T

to fix this, it might be possible to add explicit .load() and .store() calls. or, a std::atomic_flag could be used instead. i haven't tried any patches since i'm not familiar with the code.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions