Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

atomic_shared_ptr.h doesn't compile with gcc-9.3 / C++20 #105

Closed
maxgolov opened this issue Jun 11, 2020 · 3 comments
Closed

atomic_shared_ptr.h doesn't compile with gcc-9.3 / C++20 #105

maxgolov opened this issue Jun 11, 2020 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@maxgolov
Copy link
Contributor

Implementation suggests that it's C++20 compatible here:

* This wrapper relies on std::atomic for C++20, a mutex for gcc 4.8, and

However, if the project is built with

set(CMAKE_CXX_STANDARD 20)

Then the build is broken here:

opentelemetry::sdk::AtomicSharedPtr<SpanProcessor> processor_;

With the following error:

[ 50%] Building CXX object sdk/src/trace/CMakeFiles/opentelemetry_trace.dir/tracer_provider.cc.o
In file included from /mnt/c/work/opentelemetry-cpp/sdk/include/opentelemetry/sdk/common/atomic_shared_ptr.h:3,
                 from /mnt/c/work/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/tracer.h:3,
                 from /mnt/c/work/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/tracer_provider.h:9,
                 from /mnt/c/work/opentelemetry-cpp/sdk/src/trace/tracer_provider.cc:1:
/usr/include/c++/9/atomic: In instantiation of ‘struct std::atomic<std::shared_ptr<opentelemetry::v0::sdk::trace::SpanProcessor> >’:
/mnt/c/work/opentelemetry-cpp/sdk/include/opentelemetry/sdk/common/atomic_shared_ptr.h:33:35:   required from ‘class opentelemetry::v0::sdk::AtomicSharedPtr<opentelemetry::v0::sdk::trace::SpanProcessor>’
/mnt/c/work/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/tracer.h:47:54:   required from here
/usr/include/c++/9/atomic:191:21: error: static assertion failed: std::atomic requires a trivially copyable type
  191 |       static_assert(__is_trivially_copyable(_Tp),
@maxgolov maxgolov added the bug Something isn't working label Jun 11, 2020
@maxgolov
Copy link
Contributor Author

maxgolov commented Jun 11, 2020

I was evaluating what happens when we build on latest Ubuntu release with its stock compiler in a project that is targeting C++20. The build is not gonna succeed. Workaround is to avoid using std::atomic if compiling with C++20:

#if 0 /* __cplusplus > 201703L */

@pyohannes
Copy link
Contributor

I can look into this. The related template specialization is supposed to be part of C++20.

@maxgolov
Copy link
Contributor Author

Fixed by #114

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants