Skip to content

[Question] error: increases required alignment of target type #636

@nesc1

Description

@nesc1

Hi there, sorry but I don't know if this is the best place to put my question.

I'm testing the library and I want that my events have state, and that state can be std::string.

Strange when i compile my project on clang there is no problem but if i compile it on gcc i have the following error on the events that has std::string:

sml.hpp:675:5: error: cast from 'boost::ext::sml::v1_1_11::aux::byte*' {aka 'unsigned char*'} to 'MyEvent*' increases required alignment of target type [-Werror=cast-align]
[build]   675 |     reinterpret_cast<T *>(data)->~T();

where the MyEvent is simple:
struct MyEvent { std::string data; }

Two questions:

  1. why clang does not complain about this?
  2. is it possible to change this behavior of storing data, i do not have concerns about memory, my object can be copied.

I see this example where it is used the BOOST_SML_CREATE_DEFAULT_CONSTRUCTIBLE_DEPS but i did not understood if is related or not, your examples only have int's on the data.

Thank you.

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