From 3668bd6b30ff1b21e2539f9038582cb9c29beb89 Mon Sep 17 00:00:00 2001 From: Jan Polasek Date: Thu, 2 Jan 2020 15:26:52 +0000 Subject: [PATCH] Fix under-alignment issues: https://github.com/cameron314/concurrentqueue/issues/177 --- concurrentqueue.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/concurrentqueue.h b/concurrentqueue.h index 53541bc0..cb88b81d 100644 --- a/concurrentqueue.h +++ b/concurrentqueue.h @@ -1485,7 +1485,7 @@ class ConcurrentQueue enum InnerQueueContext { implicit_context = 0, explicit_context = 1 }; - struct MOODYCAMEL_ALIGNAS(MOODYCAMEL_ALIGNOF(T)) Block + struct Block { Block() : next(nullptr), elementsCompletelyDequeued(0), freeListRefs(0), freeListNext(nullptr), shouldBeOnFreeList(false), dynamicallyAllocated(true) @@ -1600,7 +1600,7 @@ class ConcurrentQueue // IMPORTANT: This must be the first member in Block, so that if T depends on a specific alignment, // that alignment will be preserved. Apparently clang actually generates code that uses this assumption // for AVX instructions in some cases. - char elements[sizeof(T) * BLOCK_SIZE]; + MOODYCAMEL_ALIGNAS(MOODYCAMEL_ALIGNOF(T)) char elements[sizeof(T) * BLOCK_SIZE]; public: Block* next; std::atomic elementsCompletelyDequeued;