Skip to content

fix: pointer slot never reads a reference dep and vice versa (#727) - #738

Merged
kris-jusiak merged 2 commits into
boost-ext:masterfrom
PavelGuzenfeld:fix/issue-727-pointer-slot-from-ref-dep
Oct 18, 2026
Merged

kris-jusiak merged 2 commits into
boost-ext:masterfrom
PavelGuzenfeld:fix/issue-727-pointer-slot-from-ref-dep

Conversation

@PavelGuzenfeld

Copy link
Copy Markdown
Contributor

A pointer slot next to a same-type reference dep was built from the reference (pool_type<base*>::pool_type(base&)), and a reference slot next to a pointer dep from the pointer. A dep of the other kind now counts as missing, so the pointer slot stays null like before. A base& slot beside a base* dep and a derived& binds the derived object.

Two tests in dependencies.cpp, both failed to compile before. Full ft suite on gcc 14 (C++14/17/20), clang 21 (C++17), MSVC 19.51 (C++20).

#737 (missing pointer dep compiles to null) is untouched, the existing missing_void_ptr_dep test asserts null.

Closes #727

PavelGuzenfeld and others added 2 commits October 17, 2026 21:52
…xt#727)

A pointer slot next to a same-type reference dep was built from the
reference, and a reference slot next to a pointer dep from the pointer.
A dep of the other kind now counts as missing. A reference slot still
finds a derived reference dep beside a pointer dep.
@kris-jusiak
kris-jusiak merged commit 132534a into boost-ext:master Oct 18, 2026
7 checks passed
Comment thread test/ft/dependencies.cpp
base727 base;
derived727 derived;
other727 other;
sml::sm<c727> sm{&base, derived, other};

Copy link
Copy Markdown
Contributor

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.

Comment thread test/ft/dependencies.cpp
struct c727 {
auto operator()() noexcept {
using namespace sml;
auto check = [](base727 &r, base727 *p, other727 &) { expect(5 == r.val && nullptr == p); };

Copy link
Copy Markdown
Contributor

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_DEPS is 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, or std::adressof(base).

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.

Pointer dependency slot initialized from a reference dependency of the same type

3 participants