File: pr85388-6.c

package info (click to toggle)
gcc-riscv64-unknown-elf 8.3.0.2019.08%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 680,956 kB
  • sloc: ansic: 3,237,715; cpp: 896,882; ada: 772,854; f90: 144,254; asm: 68,788; makefile: 67,456; sh: 29,743; exp: 28,045; objc: 15,273; fortran: 11,885; python: 7,369; pascal: 5,375; awk: 3,725; perl: 2,872; yacc: 316; xml: 311; ml: 285; lex: 198; haskell: 122
file content (56 lines) | stat: -rw-r--r-- 1,321 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* { dg-do run { target { i?86-*-linux* i?86-*-gnu* x86_64-*-linux* } } } */
/* { dg-require-effective-target cet } */
/* { dg-require-effective-target split_stack } */
/* { dg-options "-fsplit-stack -O2 -fcf-protection" } */
/* { dg-options "-fsplit-stack -O2 -mno-accumulate-outgoing-args -fcf-protection" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */

/* A case that used to fail on 32-bit x86 when optimizing and not
   using -maccumulate-args.  The stack adjustment of the alloca got
   mixed up with the arguments pushed on the stack to the function
   before the call of alloca.  */

#include <stdlib.h>

typedef struct { const char* s; int l; } s;

typedef unsigned long long align16 __attribute__ ((aligned(16)));

s gobats (const void *, int) __attribute__ ((noinline));

s
gobats (const void* p __attribute__ ((unused)),
	int l __attribute__ ((unused)))
{
  s v;
  v.s = 0;
  v.l = 0;
  return v;
}

void check_aligned (void *p) __attribute__ ((noinline));

void
check_aligned (void *p)
{
  if (((__SIZE_TYPE__) p & 0xf) != 0)
    abort ();
}

void gap (void *) __attribute__ ((noinline));

void gap (void *p)
{
  align16 a;
  check_aligned (&a);
}

int
main (int argc, char **argv)
{
  s *space;
  gobats(0, 16);
  space = (s *) alloca(sizeof(s) + 1);
  *space = (s){0, 16};
  gap(space);
  return 0;
}