Repository navigation
Open
Description
Issue Summary
When using the CFront-ABI, the generated C does not respect the alignas specifier semantics of Microsoft-mode.
When using the IA64-ABI, the generated C code is correct.
Reproducing Source Code
struct B { alignas(16) char c; };
struct D : B { char d; };
extern "C" int printf(const char *, ...);
int main() {
D x;
long fe_offset = __builtin_offsetof(D, d); // Front end's layout.
long be_offset = (char *)&x.d - (char *)&x; // Lowered C's layout.
printf("%ld %ld\n", fe_offset, be_offset);
return fe_offset != be_offset;
}
Command-line Options
cpfe --ms_c++20 --target linux_aarch64 test.cpp
Type of Issue
[Back End] There is a problem with the generated C code.
Additional Details
The reduction in size is caused by the following logic in layout.c:
#if MICROSOFT_EXTENSIONS_ALLOWED
if (microsoft_mode) {
a_targ_alignment max_alignment_for_base_class;
/* MSVC ignores explicitly-specified alignment requirements that are more
strict than platform-specific defaults when calculating the size of a
a base class. */
max_alignment_for_base_class = current_max_alignment_for_class_members();
if (max_alignment_for_base_class == 0) {
if (target_is_arm_based() || !target_is_64_bits()) {
max_alignment_for_base_class = 8;
} else {
max_alignment_for_base_class = 16;
} /* if */
} /* if */
if (max_alignment_for_base_class < (target_is_64_bits() ? 16u : 8u) &&
max_alignment_for_base_class < class_type->alignment) {
...
if (do_alignment(&end_of_fields_byte_offset, &bit_offset,
max_alignment_for_base_class)) {
ctsp->size_without_virtual_base_classes = end_of_fields_byte_offset;This was observed due to variance in processing of the test edg/cmeerw/gnats-27181-run.sft.cpp between IA64 and CFront ABIs for #460.
Reproducing (Standard) Configuration(s)
No response
Reproducing (Non-standard) Configuration
Any config with IA64_ABI=0 and Microsoft mode support on non-x86_64 targets.
I acknowledge that:
- I have checked open issues and existing discussions before filing this report.
- The reproducing source code that I have provided does not depend on headers that I have not included with my submission.
- I have reduced the reproducing source code to the best of my ability.
- I have selected at least one standard configuration or uploaded a non-standard configuration dump.
- I understand code shared via this form is NOT confidential.
- I have permission to share the reproducing source code and grant permission for the project to use the source code (or derivatives of the source code) to create tests.
- I agree that any tests created using the reproducing source code (or deriatives of it) will be licensed under project license unless I included a
LICENSE.txtfile in my.zipor.tar.gzupload. If I included aLICENSE.txtfile, any tests created using the reproducing source code will be governed by the terms of the license I provided instead.
Metadata
Metadata
Assignees
Labels
No labels
Activity
Fix bug with IL lowering on CFront ABI where padding was not correctl…
Fix bug with IL lowering on CFront ABI where padding was not correctl…
Fix bug with IL lowering on CFront ABI where padding was not correctl…