summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/stackprotectexplicit1.c
blob: 658c297d9f58e74f56309a6f97fa623700d04817 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* { dg-do run { target native } } */
/* { dg-options "-fstack-protector-explicit" } */
/* { dg-require-effective-target fstack_protector } */

#include <stdlib.h>

void
__stack_chk_fail (void)
{
  exit (0); /* pass */
}

int __attribute__((stack_protect)) main ()
{
  int i;
  char foo[255];

  // smash stack
  for (i = 0; i <= 400; i++)
    foo[i] = 42;

  return 1; /* fail */
}