Skip to content

Commit

Permalink
[BUILD] Avoid buggy "should be explicitly initialized in the copy con…
Browse files Browse the repository at this point in the history
…structor" warning with gcc <= 8 (#3087)

gcc <= 8, when building with -Wextra (and -Werror) wrongly raises this:
/data/mwrep/res/mdw/SIOTF/internal/opentelemetry_cpp/trace/18-0-0-7/include/opentelemetry/trace/default_span.h: In copy constructor 'opentelemetry::v1::trace::DefaultSpan::DefaultSpan(const opentelemetry::v1::trace::DefaultSpan&)':
/data/mwrep/res/mdw/SIOTF/internal/opentelemetry_cpp/trace/18-0-0-7/include/opentelemetry/trace/default_span.h:70:3: error: base class 'class opentelemetry::v1::trace::Span' should be explicitly initialized in the copy constructor [-Werror=extra]
   DefaultSpan(const DefaultSpan &spn) noexcept : span_context_(spn.GetContext()) {}
   ^~~~~~~~~~~

See on Compiler Explorer here: https://godbolt.org/z/ed5rv74nT

I believe Jason Merrill fixed it in gcc for all gcc >= 9 with:
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=f3f7cefecc833b4ab652215ceb8b408c21dca225;hp=777083bb806dbe31ab97002b7d445191d3ee7a2d

Workaround this by calling explicitly the empty Span constructor.
  • Loading branch information
Romain-Geissler-1A authored Oct 8, 2024
1 parent 0ea1f2c commit 3d9c2b5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions api/include/opentelemetry/trace/default_span.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class DefaultSpan : public Span
DefaultSpan(SpanContext span_context) noexcept : span_context_(span_context) {}

// movable and copiable
DefaultSpan(DefaultSpan &&spn) noexcept : span_context_(spn.GetContext()) {}
DefaultSpan(const DefaultSpan &spn) noexcept : span_context_(spn.GetContext()) {}
DefaultSpan(DefaultSpan &&spn) noexcept : Span(), span_context_(spn.GetContext()) {}
DefaultSpan(const DefaultSpan &spn) noexcept : Span(), span_context_(spn.GetContext()) {}

private:
SpanContext span_context_;
Expand Down

2 comments on commit 3d9c2b5

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'OpenTelemetry-cpp api Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 3d9c2b5 Previous: 0ea1f2c Ratio
BM_NaiveSpinLockThrashing/2/process_time/real_time 0.5295259067994663 ms/iter 0.23274141573937776 ms/iter 2.28
BM_NaiveSpinLockThrashing/4/process_time/real_time 1.9063019752502441 ms/iter 0.83525649836806 ms/iter 2.28

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'OpenTelemetry-cpp sdk Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 3d9c2b5 Previous: 0ea1f2c Ratio
BM_BaselineBuffer/2 13763451.57623291 ns/iter 3793132.076385433 ns/iter 3.63
BM_BaselineBuffer/4 15481059.551239014 ns/iter 3998119.3085840833 ns/iter 3.87
BM_LockFreeBuffer/2 6801941.394805908 ns/iter 2641474.359027955 ns/iter 2.58
BM_LockFreeBuffer/4 10970928.66897583 ns/iter 2934619.3186938763 ns/iter 3.74

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.