Skip to content

std::atomic<std::shared_ptr<T>> not compiling with emcc 3.1.42 / clang 17.0.0 #21733

Closed
@dsamo

Description

@dsamo

When compiling this with emcc -std=c++20 test.cpp it should be working. However, I get an error as if I am compiling with c++17 and below.

#include <memory>
#include <atomic>

struct A
{
	void bar()
	{
		foo = nullptr;
	}

	std::atomic<std::shared_ptr<int>> foo; // error: _Atomic cannot be applied to type 'std::shared_ptr<int>' which is 
                                               // not trivially copyable
};

int main()
{
	A a;
	a.bar();
	return 0;
}

Afaik clang >= 15 can compile this in c++ 20. Am I missing something here? Environment:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.42 (6ede0b8fc1c979bb206148804bfb48b472ccc3da)
clang version 17.0.0 (https://github.com/llvm/llvm-project f3b64887de61020c09404bfee97b2fadd30df10a)
Target: wasm32-unknown-emscripten
Thread model: posix

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions