Skip to content

fix -Wcast-align in queue_event - #664

Merged
kris-jusiak merged 2 commits into
boost-ext:masterfrom
PavelGuzenfeld:fix/queue-event-cast-align
May 22, 2026
Merged

kris-jusiak merged 2 commits into
boost-ext:masterfrom
PavelGuzenfeld:fix/queue-event-cast-align

Conversation

@PavelGuzenfeld

Copy link
Copy Markdown
Contributor

Fixes #636.

queue_event::dtor_impl took aux::byte* then reinterpret_cast<T*>, which GCC flags as -Wcast-align when T has alignment stricter than 1 (e.g. std::string on some ABIs, or explicitly over-aligned types).

The storage is already aligned via alignas(alignment), so the cast is safe — only the parameter type is misleading. Fix: use void* for the destructor function pointer and static_cast in both dtor_impl and move_impl.

Both process_event and process_defer_events tracked state changes by
comparing only current_state_[0] (first region). A transition in any
other region left changed=false, preventing deferred events from being
replayed.

Fix: compare all regions when detecting state change.

Closes #611
dtor_impl took aux::byte* (alignment 1) then reinterpret_cast<T*>,
triggering -Wcast-align when T has stricter alignment (e.g. std::string
or user-defined over-aligned structs). The storage is already properly
aligned via alignas(alignment), so the cast itself is safe — only the
type annotation is misleading.

Use void* for the dtor function pointer and static_cast in both
dtor_impl and move_impl. Closes #636.
@kris-jusiak
kris-jusiak merged commit 1678434 into boost-ext:master May 22, 2026
5 checks passed
@PavelGuzenfeld
PavelGuzenfeld deleted the fix/queue-event-cast-align branch May 27, 2026 13:58
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.

[Question] error: increases required alignment of target type

2 participants