Constrain maybe::assign to types with has_value()/value()#7
Open
HFTrader wants to merge 2 commits intoCons-Cat:mainfrom
Open
Constrain maybe::assign to types with has_value()/value()#7HFTrader wants to merge 2 commits intoCons-Cat:mainfrom
HFTrader wants to merge 2 commits intoCons-Cat:mainfrom
Conversation
The unconstrained template accepted any type including plain int, causing compilation errors when assign() called .has_value() on non-maybe types. Add requires clause to all three storage variants. Fixes Cons-Cat#5, Cons-Cat#6
1. is_common_comparison_category: concept used && where || was needed, making it always false and lexicographical_compare_three_way uncallable 2. maybe_value_storage::assign: hard_reset() destroyed m_storage before reading from the maybe parameter, causing use-after-destroy on self-assignment 3. divide_by: wrap and saturate branches called wrap_mul/sat_mul instead of wrap_div/sat_div (author-acknowledged TODO)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Four bugs found via clang-tidy 23 (trunk) analysis:
1. Constrain
maybe::assigntemplate (commit 1)requiresclause to all threeassigntemplate overloadsint, causing compilation errors2. Fix
is_common_comparison_categoryconcept (commit 2)&&to||— the concept was always false since no type can simultaneously bestrong_ordering,weak_ordering, ANDpartial_orderinglexicographical_compare_three_wayuncallable3. Fix
maybe_value_storage::assignself-assignment (commit 2)hard_reset()destroyedm_storagebefore the assignment read from themaybeparametermaybealiasedm_storage, this was use-after-destroy__builtin_addressofguard4. Fix
divide_bycalling wrong functions (commit 2)wrap_mul/sat_mulinstead ofwrap_div/sat_divBuild verification
Fixes #5, #6