https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127650
Bug ID: 127650
Summary: `va_arg` of an over-aligned emits `movdqa` from an
8-mod-16 address and cause SIGSEGV
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: kyuwoncho18 at gmail dot com
Target Milestone: ---
#include <stdarg.h>
#include <stdio.h>
struct S { long a, b, c, d, e, f, g, h; };
typedef struct S S32 __attribute__((aligned(32)));
struct S gg;
void f (int n, int b, int c, int d, int e, int g, ...)
{
va_list ap;
va_start (ap, g);
long L = va_arg (ap, long);
gg = va_arg (ap, S32);
printf ("L=%ld a=%ld h=%ld\n", L, gg.a, gg.h);
va_end (ap);
}
int
main (void)
{
S32 s = {0};
f (0, 1, 2, 3, 4, 5, 0L, s);
return 0;
}
With -O{1,2,3}, it raises SIGSEGV with movdqa xmm0, xmmword ptr [rsp + 0x104],
and the address was not 16-byte-aligned.
https://gcc.godbolt.org/z/q1bGaKda9