Skip to content

[AArch64][ARM] Why fpack-struct=4 has a higher priority than attribute #103495

@LukeSTM

Description

@LukeSTM
struct s1
{
  int __attribute__ ((aligned (8))) a;
};

struct
{
  char c;
  struct s1 m;
} v;

int
main (void)
{
  if ((int)&v.m & 7)
    abort ();
  exit (0);
}

compile with only one option:-fpack-struct=4

gcc could pass this testcase, but clang could not.
https://godbolt.org/z/h5T5rdYWb

The code can be simplified as follows:

struct s1
{
  int __attribute__ ((aligned (8))) a;
}s;

https://godbolt.org/z/EbGsEz6eP
image

if compile without -fpack-struct=4, the alignment of struct is 8, as same as attribue. But if compile with -fpack-struct=4, the alignment of struct is 4. Why fpack-struct=4 has a higher priority than attribute? I think attribute should has a higher priority than Compilation options

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:codegenIR generation bugs: mangling, exceptions, etc.questionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions