Skip to content

back11: undefined behaviour (reported by llvm 18) #81

@matthijs

Description

@matthijs

Hi,

Compiler: clang++-18
Boost: version 1.86.0

I have the following statemachine:

#include <iostream>

#include <boost/msm/back11/state_machine.hpp>
#include <boost/msm/front/puml/puml.hpp>
#include <boost/msm/front/state_machine_def.hpp>

namespace msm = boost::msm;
using namespace msm::front;
using namespace msm::front::puml;

namespace boost::msm::front::puml {

// Actions
template <> struct Action<by_name("a_connected")> {
  template <typename Event, typename FSM, typename SourceState,
            typename TargetState>
  void operator()(const Event &, FSM &, SourceState &, TargetState &) {
    std::cout << "server connected" << std::endl;
  }
};
} // namespace boost::msm::front::puml

struct server_ : public msm::front::state_machine_def<server_> {
  int chain_id{0};
  int job_id{0};
  BOOST_MSM_PUML_DECLARE_TABLE(R"(
@startuml server
state Server {
[*]       --> Initial
Initial   --> Connected : connected / a_connected
}
@enduml
)")
};
using server = msm::back11::state_machine<server_>;
using connected = Event<by_name("connected")>;

int main(int, char **) {

  // server
  server sm;
  sm.process_event(connected{});

  return 0;
}

When compiling and executing:

$ /usr/bin/clang++-18 -isystem /home/matthijs/src/boost/boost_1_86_0 -fno-omit-frame-pointer -O1 -fsanitize=address,undefined,pointer-compare,pointer-subtract,leak -fsanitize-address-use-after-scope -Wall -Wextra -g -std=gnu++20 ../main.cpp -o main
$ ./main
/home/matthijs/src/boost/boost_1_86_0/boost/msm/back11/state_machine.hpp:2171:21: runtime error: call to function boost::msm::back11::state_machine<server_, void, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>::a_row_<boost::msm::front::Row<boost::msm::front::puml::State<2389040076u, boost::fusion::vector<>, boost::fusion::vector<>, boost::fusion::vector<>>, boost::msm::front::puml::Event<3846760266u>, boost::msm::front::puml::State<1740203497u, boost::fusion::vector<>, boost::fusion::vector<>, boost::fusion::vector<>>, boost::msm::front::puml::Action<2978207285u>, boost::msm::front::none>>::execute(boost::msm::back11::state_machine<server_, void, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>&, int, int, boost::msm::front::puml::Event<3846760266u> const&) through pointer to incorrect function type 'boost::msm::back::HandledEnum (*)(boost::msm::back11::state_machine<server_> &, int, int, boost::msm::front::puml::Event<3846760266> &)'
/home/matthijs/src/boost/boost_1_86_0/boost/msm/back11/state_machine.hpp:590: note: boost::msm::back11::state_machine<server_, void, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>::a_row_<boost::msm::front::Row<boost::msm::front::puml::State<2389040076u, boost::fusion::vector<>, boost::fusion::vector<>, boost::fusion::vector<>>, boost::msm::front::puml::Event<3846760266u>, boost::msm::front::puml::State<1740203497u, boost::fusion::vector<>, boost::fusion::vector<>, boost::fusion::vector<>>, boost::msm::front::puml::Action<2978207285u>, boost::msm::front::none>>::execute(boost::msm::back11::state_machine<server_, void, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>&, int, int, boost::msm::front::puml::Event<3846760266u> const&) defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/matthijs/src/boost/boost_1_86_0/boost/msm/back11/state_machine.hpp:2171:21
server connected

I am not sure if this is a serious problem. If you need more information let me know.

Regards, Matthijs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions