Memory alignment incompatibility between clang-cl (18.1.0 and 19.1.5) and MSVC v19 latest when using push/pop packing and /Zp8
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
The incompatibility occurs when memory alignment is applied for an empty base class and for classes inheriting from these base classes.
At the same time the argument /Zp8 and the pragma push/pop pack needs to be used.
Check the following link with the code snippets that prints output for the class memory layout. In the output for each compiler check the offset of Derived::m_derived:
For msvc it is 48.
For clang it is 40.
https://gcc.godbolt.org/z/sdcEhxM9E (this time with --target=x86_64-pc-windows-msvc enabled)
The link uses clang 18.1.0, but I could also reproduce it locally using 19.1.5 - however godbolt does not provide that version for clang-cl yet.
Contributor guide
Research direction
Start with the Compiler Explorer reproduction at https://gcc.godbolt.org/z/sdcEhxM9E and compare the class-layout output for clang-cl and MSVC with /Zp8 and pragma pack push/pop. Focus on the offset of Derived::m_derived, and consider the issue addressed when the memory layout behavior is compatible between the compilers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100