eclipse-iceoryx / iceoryx

Eclipse iceoryx™ - true zero-copy inter-process-communication
https://iceoryx.io
Apache License 2.0
1.65k stars 384 forks source link

iox-#2011 Solve a warning when building in Release mode. #2298

Closed clalancette closed 3 months ago

clalancette commented 3 months ago

When building the iceoryx_hoofs package from the release_2.0 branch in Release mode (-DCMAKE_BUILD_TYPE=Release), with gcc 13, we get warnings like the following:

In file included from /home/ubuntu/rolling_ws/src/eclipse-iceoryx/iceoryx/iceoryx_posh/source/popo/subscriber_options.cpp:17:
In constructor ‘iox::popo::SubscriberOptions::SubscriberOptions(iox::popo::SubscriberOptions&&)’,
    inlined from ‘bool iox::cxx::variant<Types>::emplace_at_index(CTorArguments&& ...) [with long unsigned int TypeIndex = 0; CTorArguments = {iox::popo::SubscriberOptions}; Types = {iox::popo::SubscriberOptions, iox::cxx::Serialization::Error}]’ at /home/ubuntu/rolling_ws/install/iceoryx_hoofs/include/iceoryx/v2.0.6/iceoryx_hoofs/internal/cxx/variant.inl:174:5,
    inlined from ‘constexpr iox::cxx::variant<Types>::variant(const iox::cxx::in_place_index<N>&, CTorArguments&& ...) [with long unsigned int N = 0; CTorArguments = {iox::popo::SubscriberOptions}; Types = {iox::popo::SubscriberOptions, iox::cxx::Serialization::Error}]’ at /home/ubuntu/rolling_ws/install/iceoryx_hoofs/include/iceoryx/v2.0.6/iceoryx_hoofs/internal/cxx/variant.inl:42:24,
    inlined from ‘iox::cxx::expected<ValueType, ErrorType>::expected(iox::cxx::success<ValueType>&&) [with ValueType = iox::popo::SubscriberOptions; ErrorType = iox::cxx::Serialization::Error]’ at /home/ubuntu/rolling_ws/install/iceoryx_hoofs/include/iceoryx/v2.0.6/iceoryx_hoofs/internal/cxx/expected.inl:93:7,
    inlined from ‘static iox::cxx::expected<iox::popo::SubscriberOptions, iox::cxx::Serialization::Error> iox::popo::SubscriberOptions::deserialize(const iox::cxx::Serialization&)’ at /home/ubuntu/rolling_ws/src/eclipse-iceoryx/iceoryx/iceoryx_posh/source/popo/subscriber_options.cpp:56:61:
/home/ubuntu/rolling_ws/src/eclipse-iceoryx/iceoryx/iceoryx_posh/include/iceoryx_posh/popo/subscriber_options.hpp:32:8: warning: ‘queueFullPolicy’ may be used uninitialized [-Wmaybe-uninitialized]
   32 | struct SubscriberOptions
      |        ^~~~~~~~~~~~~~~~~
/home/ubuntu/rolling_ws/src/eclipse-iceoryx/iceoryx/iceoryx_posh/source/popo/subscriber_options.cpp: In static member function ‘static iox::cxx::expected<iox::popo::SubscriberOptions, iox::cxx::Serialization::Error> iox::popo::SubscriberOptions::deserialize(const iox::cxx::Serialization&)’:
/home/ubuntu/rolling_ws/src/eclipse-iceoryx/iceoryx/iceoryx_posh/source/popo/subscriber_options.cpp:40:23: note: ‘queueFullPolicy’ was declared here
   40 |     QueueFullPolicyUT queueFullPolicy;
      |       

This change avoids the warning by just always assigning a zero. However, this isn't really a serious attempt at a fix, but more of a way to start a discussion. I noticed that the main branch compiles without warnings, but does not have this zero in place. That said, I do not understand the mechanism that is being used there, so I'm having trouble tracking down the difference between the main branch and this one. Any thoughts on the "correct" way to fix this?

(skipping the rest of the checklist for now until we decide what to do here)

Notes for Reviewer

Pre-Review Checklist for the PR Author

  1. [x] Code follows the coding style of CONTRIBUTING.md
  2. [x] Tests follow the best practice for testing
  3. [x] Changelog updated in the unreleased section including API breaking changes
  4. [x] Branch follows the naming format (iox-123-this-is-a-branch)
  5. [x] Commits messages are according to this guideline
  6. [x] Update the PR title
    • Follow the same conventions as for commit messages
    • Link to the relevant issue
  7. [x] Relevant issues are linked
  8. [x] Add sensible notes for the reviewer
  9. [x] All checks have passed (except task-list-completed)
  10. [x] Assign PR to reviewer

Checklist for the PR Reviewer

Post-review Checklist for the PR Author

  1. [x] All open points are addressed and tracked via issues

References

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 78.47%. Comparing base (434ee45) to head (a4a1157). Report is 3 commits behind head on release_2.0.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx/pull/2298/graphs/tree.svg?width=650&height=150&src=pr&token=KWu8wdCc1S&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx)](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx/pull/2298?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx) ```diff @@ Coverage Diff @@ ## release_2.0 #2298 +/- ## =============================================== - Coverage 78.49% 78.47% -0.03% =============================================== Files 370 370 Lines 14217 14219 +2 Branches 2060 2060 =============================================== - Hits 11160 11158 -2 - Misses 2372 2377 +5 + Partials 685 684 -1 ``` | [Flag](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx/pull/2298/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx/pull/2298/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx) | `77.70% <100.00%> (-0.02%)` | :arrow_down: | | [unittests_timing](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx/pull/2298/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx) | `15.12% <0.00%> (-0.03%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx/pull/2298?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx) | Coverage Δ | | |---|---|---| | [iceoryx\_posh/source/popo/publisher\_options.cpp](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx/pull/2298?src=pr&el=tree&filepath=iceoryx_posh%2Fsource%2Fpopo%2Fpublisher_options.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx#diff-aWNlb3J5eF9wb3NoL3NvdXJjZS9wb3BvL3B1Ymxpc2hlcl9vcHRpb25zLmNwcA==) | `100.00% <100.00%> (ø)` | | | [iceoryx\_posh/source/popo/subscriber\_options.cpp](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx/pull/2298?src=pr&el=tree&filepath=iceoryx_posh%2Fsource%2Fpopo%2Fsubscriber_options.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx#diff-aWNlb3J5eF9wb3NoL3NvdXJjZS9wb3BvL3N1YnNjcmliZXJfb3B0aW9ucy5jcHA=) | `93.75% <100.00%> (+0.41%)` | :arrow_up: | ... and [3 files with indirect coverage changes](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx/pull/2298/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx)
elBoberido commented 3 months ago

Once again, thanks for fixing the warnings. Could you please add iox-#210 to the commit message ... and push ;)

clalancette commented 3 months ago

Once again, thanks for fixing the warnings. Could you please add iox-#210 to the commit message ... and push ;)

Sorry for the delay here. I've now done that.