mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 05:37:54 +00:00
base-hw: Fix invalid structure alignments.
According to C++11 reference: "If the strictest (largest) alignas on a declaration is weaker than the alignment it would have without any alignas specifiers (that is, weaker than its natural alignment or weaker than alignas on another declaration of the same object or type), the program is ill-formed:" https://en.cppreference.com/w/cpp/language/alignas The code requests 4 byte alignment for Genode::Arm_cpu::Context. The Context structure inherits Genode::Arm_cpu::Fpu_context which has minimum alignment requirement of 8 bytes, due to uint64_t d0_d31 member. This makes the 4 byte value in Context's alignas specifier invalid (smaller than allowed minimum). Similar situation takes place in Arm_64 case. The claimed minimum alignment of Context is 8 bytes, but the fpu_state member imposes 16 bytes alignment (explicitly specified in Fpu_state declaration). In both cases the code builds fine with GCC 8.3.0, but fails with clang which claims that "requested alignment is less than minimum alignment of X for type", where X is 8 on ARM and 16 on AArch64. Ref: https://eel.is/c++draft/dcl.align#5 Issue #4421
This commit is contained in:
parent
468057638b
commit
4ae78639f5
@ -47,7 +47,7 @@ struct Genode::Arm_cpu : public Hw::Arm_cpu
|
||||
uint64_t d0_d31[32]; /* VFP/SIMD - general purpose registers */
|
||||
};
|
||||
|
||||
struct alignas(4) Context : Cpu_state, Fpu_context
|
||||
struct alignas(8) Context : Cpu_state, Fpu_context
|
||||
{
|
||||
Context(bool privileged);
|
||||
};
|
||||
|
@ -71,7 +71,7 @@ struct Genode::Cpu : Hw::Arm_64_cpu
|
||||
Genode::uint64_t fpcr;
|
||||
};
|
||||
|
||||
struct alignas(8) Context : Cpu_state
|
||||
struct alignas(16) Context : Cpu_state
|
||||
{
|
||||
Genode::uint64_t pstate { };
|
||||
Genode::uint64_t exception_type { RESET };
|
||||
|
Loading…
Reference in New Issue
Block a user