blob: a4f0f8163103ae107cabc293954c15b7794b816c (
plain)
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
|
/* Test that stack protection is done on chosen functions. */
/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
/* { dg-options "-O2 -fstack-protector-strong" } */
class A
{
public:
A() {}
~A() {}
void method();
int state;
};
/* Frame address exposed to A::method via "this". */
int
foo1 ()
{
A a;
a.method ();
return a.state;
}
/* Possible destroying foo2's stack via &a. */
int
global_func (A& a);
/* Frame address exposed to global_func. */
int foo2 ()
{
A a;
return global_func (a);
}
/* { dg-final { scan-assembler-times "stack_chk_fail" 2 } } */
|