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

[BUILD] Avoid buggy warning with gcc <= 8 #3087

Merged

Conversation

Romain-Geissler-1A
Copy link
Contributor

@Romain-Geissler-1A Romain-Geissler-1A commented Oct 8, 2024

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.

…" warning with gcc <= 8

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.
@Romain-Geissler-1A Romain-Geissler-1A requested a review from a team as a code owner October 8, 2024 13:25
Copy link

netlify bot commented Oct 8, 2024

Deploy Preview for opentelemetry-cpp-api-docs canceled.

Name Link
🔨 Latest commit 6c04bf2
🔍 Latest deploy log https://app.netlify.com/sites/opentelemetry-cpp-api-docs/deploys/670532b9ade31200093a0cc3

Copy link

codecov bot commented Oct 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.82%. Comparing base (497eaf4) to head (6c04bf2).
Report is 138 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3087      +/-   ##
==========================================
+ Coverage   87.12%   87.82%   +0.71%     
==========================================
  Files         200      195       -5     
  Lines        6109     5968     -141     
==========================================
- Hits         5322     5241      -81     
+ Misses        787      727      -60     
Files with missing lines Coverage Δ
api/include/opentelemetry/trace/default_span.h 13.34% <ø> (ø)

... and 125 files with indirect coverage changes

Copy link
Member

@lalitb lalitb left a comment

Choose a reason for hiding this comment

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

LGTM. Generally, I am not in favor of providing fix for a buggy compiler, but in this case the fix is trivial, and no side effect so should be fine :)

@marcalff
Copy link
Member

marcalff commented Oct 8, 2024

Bonjour @Romain-Geissler-1A

The links to compiler explorer and to the gcc patch makes this very convincing, thanks for the research.

LGTM.

@marcalff marcalff changed the title Avoid buggy "should be explicitly initialized in the copy constructor" warning with gcc <= 8 [BUILD] Avoid buggy "should be explicitly initialized in the copy constructor" warning with gcc <= 8 Oct 8, 2024
@marcalff marcalff merged commit 3d9c2b5 into open-telemetry:main Oct 8, 2024
56 checks passed
@marcalff marcalff changed the title [BUILD] Avoid buggy "should be explicitly initialized in the copy constructor" warning with gcc <= 8 [BUILD] Avoid buggy warning with gcc <= 8 Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants