From 21b293dbc37d42446141a08922cdec0d2550c6a0 Mon Sep 17 00:00:00 2001 From: Florian Walpen Date: Wed, 2 Feb 2022 00:58:53 +0100 Subject: Fix alignas() on non-packed architectures (#839). Unbreak the build with Clang on architectures where JACK uses non-packed data structures, like arm64 or powerpc. The alignment errors are exposed there because: * The non-packed data structures require 8 byte alignment. * alignas() is not allowed to weaken alignment requirements to 4 bytes. * Clang enforces this according to standard, GCC ignores it. Use an additional alignas() specifier to let the compiler choose between minimum alignment (packed) and "natural" alignment (non-packed). This is both standard c++11 and compatible with older GCC, which does not propagate alignment requirements of packed substructures properly. --- common/JackAtomicState.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common/JackAtomicState.h') diff --git a/common/JackAtomicState.h b/common/JackAtomicState.h index 26d6a565..69c8316e 100644 --- a/common/JackAtomicState.h +++ b/common/JackAtomicState.h @@ -94,7 +94,7 @@ class JackAtomicState protected: T fState[2]; - alignas(UInt32) volatile AtomicCounter fCounter; + alignas(UInt32) alignas(AtomicCounter) volatile AtomicCounter fCounter; SInt32 fCallWriteCounter; UInt32 WriteNextStateStartAux() -- cgit v1.2.1