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

iox-#1823 Fix double move in emplace #1825

Merged
merged 3 commits into from
Dec 15, 2022

Conversation

elfenpiff
Copy link
Contributor

@elfenpiff elfenpiff commented Dec 13, 2022

Pre-Review Checklist for the PR Author

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

Notes for Reviewer

Checklist for the PR Reviewer

  • Commits are properly organized and messages are according to the guideline
  • Code according to our coding style and naming conventions
  • Unit tests have been written for new behavior
  • Public API changes are documented via doxygen
  • Copyright owner are updated in the changed files
  • All touched (C/C++) source code files from iceoryx_hoofs have been added to ./clang-tidy-diff-scans.txt
  • PR title describes the changes

Post-review Checklist for the PR Author

  1. All open points are addressed and tracked via issues

References

@codecov
Copy link

codecov bot commented Dec 13, 2022

Codecov Report

Merging #1825 (bbb33bd) into master (6765566) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1825      +/-   ##
==========================================
+ Coverage   75.68%   75.70%   +0.01%     
==========================================
  Files         375      375              
  Lines       14565    14566       +1     
  Branches     2067     2067              
==========================================
+ Hits        11024    11027       +3     
+ Misses       2910     2909       -1     
+ Partials      631      630       -1     
Flag Coverage Δ
unittests 75.36% <100.00%> (+0.01%) ⬆️
unittests_timing 15.36% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...oofs/include/iceoryx_hoofs/internal/cxx/vector.inl 98.68% <100.00%> (+<0.01%) ⬆️
iceoryx_hoofs/source/concurrent/loffli.cpp 80.00% <0.00%> (+5.71%) ⬆️

@dkroenke dkroenke added the bugfix Solves a bug label Dec 14, 2022
Copy link
Contributor

@MatthiasKillat MatthiasKillat left a comment

Choose a reason for hiding this comment

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

Function looks correct. Redundant parentheses, no semantic influence.

@@ -174,17 +174,18 @@ template <typename T, uint64_t Capacity>
template <typename... Targs>
inline bool vector<T, Capacity>::emplace(const uint64_t position, Targs&&... args) noexcept
{
if ((m_size >= Capacity) || ((position >= Capacity) || (position > m_size)))
const auto sizeBeforeEmplace = m_size;
if ((m_size >= Capacity) || ((position >= Capacity) || (position > sizeBeforeEmplace)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if ((m_size >= Capacity) || ((position >= Capacity) || (position > sizeBeforeEmplace)))
if ((m_size >= Capacity) || (position >= Capacity) || (position > sizeBeforeEmplace))

Even with redundant brace rules this is sufficient I think.

@mossmaurice mossmaurice removed the request for review from FerdinandSpitzschnueffler December 14, 2022 18:44
@dkroenke dkroenke merged commit 928a7e6 into eclipse-iceoryx:master Dec 15, 2022
@dkroenke dkroenke deleted the iox-1823-fix-vector-emplace branch December 15, 2022 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Solves a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vector::emplace move element twice and causes undefined behavior
3 participants