Closed etam closed 5 years ago
MWE:
#include <iostream> #include <boost/sml.hpp> struct e1 {}; const auto guard = [](const int* i) { // segfaults on dereferencing i std::cout << "guard " << *i << '\n'; return true; }; const auto action = [](int* i) { std::cout << "action " << *i << '\n'; }; struct TransitionTable { auto operator()() const { using namespace boost::sml; return make_transition_table( *"s"_s + event<e1> [ guard ] / action ); } }; int main() { int i = 5; boost::sml::sm<TransitionTable> sm{&i}; sm.process_event(e1{}); }
guard takes dependency as const int* and is given nullptr. If it's changed to int* it works as expected.
guard
const int*
nullptr
int*
In the current SML version, const/non-const types have to be passed separately. That will most likely change in the future though.
https://wandbox.org/permlink/OClASgiAw8Kl5du6
MWE:
guard
takes dependency asconst int*
and is givennullptr
. If it's changed toint*
it works as expected.