Repository navigation
fix: pointer slot never reads a reference dep and vice versa (#727) #738
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
Merged
kris-jusiak
merged 2 commits into
boost-ext:master
from
PavelGuzenfeld:fix/issue-727-pointer-slot-from-ref-dep
Oct 18, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -499,6 +499,51 @@ test missing_void_ptr_dep_next_to_ref_dep = [] { | |
| expect(sm.is(sml::X)); | ||
| }; | ||
|
|
||
| struct base727 { | ||
| int val = 5; | ||
| }; | ||
| struct derived727 : base727 { | ||
| derived727() { val = 727; } | ||
| }; | ||
| struct other727 {}; | ||
|
|
||
| test pointer_slot_is_null_beside_same_type_ref_dep = [] { | ||
| struct c727 { | ||
| auto operator()() noexcept { | ||
| using namespace sml; | ||
| auto check = [](base727 &r, base727 *p, other727 &) { expect(5 == r.val && nullptr == p); }; | ||
| // clang-format off | ||
| return make_transition_table(*idle + event<e1> / check = X); | ||
| // clang-format on | ||
| } | ||
| }; | ||
|
|
||
| base727 base; | ||
| other727 other; | ||
| sml::sm<c727> sm{base, other}; | ||
| sm.process_event(e1{}); | ||
| expect(sm.is(sml::X)); | ||
| }; | ||
|
|
||
| test ref_slot_binds_derived_dep_beside_pointer_dep = [] { | ||
| struct c727 { | ||
| auto operator()() noexcept { | ||
| using namespace sml; | ||
| auto check = [](base727 &r, base727 *p, other727 &) { expect(727 == r.val && nullptr != p && 5 == p->val); }; | ||
| // clang-format off | ||
| return make_transition_table(*idle + event<e1> / check = X); | ||
| // clang-format on | ||
| } | ||
| }; | ||
|
|
||
| base727 base; | ||
| derived727 derived; | ||
| other727 other; | ||
| sml::sm<c727> sm{&base, derived, other}; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's probably another ambiguity case for which we could discuss and define the intended outcome first. |
||
| sm.process_event(e1{}); | ||
| expect(sm.is(sml::X)); | ||
| }; | ||
|
|
||
| // Issue #485: passing a pointer dependency as an lvalue caused the SM to store | ||
| // nullptr instead of the actual pointer. Root cause: forwarding reference | ||
| // deduction wraps a T* lvalue as T*&; the pool init constructor's try_get | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's probably another ambiguity case for which we could discuss and define the intended outcome first.
See #736
It is correct that base727* can be default constructed and that
BOOST_SML_CREATE_DEFAULT_CONSTRUCTIBLE_DEPSis present.On the other hand, the pointer could be initialized from the adress of the valid object the sm constructor already got, naively via
&base, orstd::adressof(base).