Skip to content

Commit

Permalink
Assert correct padding of flexible array member in frame types
Browse files Browse the repository at this point in the history
  • Loading branch information
fknorr committed Jul 15, 2022
1 parent 81bb6a2 commit 2a7437d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/buffer_transfer_manager.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <cstddef>
#include <list>
#include <memory>
#include <unordered_map>
Expand Down Expand Up @@ -47,6 +48,9 @@ namespace detail {
alignas(std::max_align_t) payload_type data[]; // max_align to allow reinterpret_casting a pointer to this member to any buffer element pointer
};

// unique_frame_ptr assumes that the flexible payload member begins at exactly sizeof(Frame) bytes
static_assert(offsetof(data_frame, data) == sizeof(data_frame));

struct transfer_in {
node_id source_nid;
MPI_Request request;
Expand Down
4 changes: 4 additions & 0 deletions include/command.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <cstddef>
#include <variant>

#include "intrusive_graph.h"
Expand Down Expand Up @@ -237,5 +238,8 @@ namespace detail {
iterable_range<const command_id*> iter_dependencies() const { return {dependencies, dependencies + num_dependencies}; }
};

// unique_frame_ptr assumes that the flexible payload member begins at exactly sizeof(Frame) bytes
static_assert(offsetof(command_frame, dependencies) == sizeof(command_frame));

} // namespace detail
} // namespace celerity

0 comments on commit 2a7437d

Please sign in to comment.