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

Avoid producing invalid iterators in division loops #309

Merged
merged 1 commit into from
Aug 6, 2024

Conversation

chfast
Copy link
Owner

@chfast chfast commented Aug 5, 2024

This decouples loop end expression from the iterator decrement. Previously, the it-- produced invalid iterator to u[-1] in the last iteration. It might have not been a big deal for execution because the loop terminated and the iterator was unused, but this was theoretical undefined behavior and constexpr context didn't like it either.

@chfast chfast requested a review from gumb0 August 5, 2024 11:14
Copy link

codecov bot commented Aug 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.94%. Comparing base (68a9dfa) to head (5510a01).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #309   +/-   ##
=======================================
  Coverage   99.94%   99.94%           
=======================================
  Files          10       10           
  Lines        1886     1890    +4     
=======================================
+ Hits         1885     1889    +4     
  Misses          1        1           
Flag Coverage Δ
32bit 99.94% <100.00%> (+<0.01%) ⬆️
gcc 99.41% <100.00%> (+<0.01%) ⬆️

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

Files Coverage Δ
include/intx/intx.hpp 99.86% <100.00%> (+<0.01%) ⬆️

@chfast
Copy link
Owner Author

chfast commented Aug 5, 2024

No performance difference observed.

@chfast chfast requested a review from rodiazet August 5, 2024 17:33
@chfast chfast force-pushed the refactor_div_loops branch from 51f866d to 3886b49 Compare August 6, 2024 08:34
This decouples loop end expression from the iterator decrement.
Previously, the `it--` produced invalid iterator to `u[-1]`
in the last iteration. It might have not been a big deal for execution
because the loop terminated and the iterator was unused,
but this was theoretical undefined behavior and constexpr context
didn't like it either.
@chfast chfast force-pushed the refactor_div_loops branch from 3886b49 to 5510a01 Compare August 6, 2024 09:21
Copy link

sonarqubecloud bot commented Aug 6, 2024

@chfast chfast merged commit 150f2de into master Aug 6, 2024
19 checks passed
@chfast chfast deleted the refactor_div_loops branch August 6, 2024 09:43
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.

2 participants