https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124671

            Bug ID: 124671
           Summary: Argument with wrong argument is passed to callee
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hjl.tools at gmail dot com
                CC: rguenther at suse dot de
  Target Milestone: ---

Since ix86_function_arg_boundary may ignore type alignment for arguments
passed on stack, when the address of argument on stack is passed to callee,
its address may not be properly aligned:

[hjl@gnu-tgl-3 pr120839]$ cat bar.c
/* { dg-do run } */
/* { dg-options "-O2" } */

#define ALIGNMENT       256

#include <stddef.h>

typedef struct {
  long double a;
  long double b;
} c __attribute__((aligned(ALIGNMENT)));

__attribute__ ((noipa))
void foo (c *p)
{
  if ((((ptrdiff_t) p) & (ALIGNMENT - 1)) != 0)
    __builtin_abort ();
}

__attribute__ ((noipa))
void
bar (c f)
{
  foo (&f);
}

c f;

int
main()
{
  bar (f);
  return 0;
}
[hjl@gnu-tgl-3 pr120839]$ /usr/gcc-16.0.1-x32/bin/gcc -O2 bar.c
[hjl@gnu-tgl-3 pr120839]$ ./a.out 
Aborted                    (core dumped) ./a.out
[hjl@gnu-tgl-3 pr120839]$

Reply via email to