diff --git a/folly/channels/detail/AtomicQueue.h b/folly/channels/detail/AtomicQueue.h index eb4dc4dc383..1bf2a903070 100644 --- a/folly/channels/detail/AtomicQueue.h +++ b/folly/channels/detail/AtomicQueue.h @@ -82,7 +82,7 @@ class AtomicQueue { public: using MessageQueue = Queue; - AtomicQueue() {} + AtomicQueue() { static_assert(alignof(Consumer) > kTypeMask); } ~AtomicQueue() { auto storage = storage_.load(std::memory_order_acquire); auto type = static_cast(storage & kTypeMask); diff --git a/folly/channels/detail/test/AtomicQueueTest.cpp b/folly/channels/detail/test/AtomicQueueTest.cpp index 6feb6392cec..bc71d3a3e07 100644 --- a/folly/channels/detail/test/AtomicQueueTest.cpp +++ b/folly/channels/detail/test/AtomicQueueTest.cpp @@ -98,7 +98,7 @@ TEST(AtomicQueueTest, Basic) { } TEST(AtomicQueueTest, Canceled) { - struct Consumer { + struct alignas(int) Consumer { void consume(int*) { ADD_FAILURE() << "consume() shouldn't be called"; } void canceled(int* consumerParam) { EXPECT_EQ(consumerParam, getConsumerParam());