Debian Codegraph @

gcc/testsuite/g++.dg/torture/except-1.C

raw
1 // { dg-do run { target { i?86-*-linux* i?86-*-gnu* x86_64-*-linux* } } }
2 // { dg-additional-options "-fexceptions -fnon-call-exceptions -fno-delete-dead-exceptions" }
3
4 #include <signal.h>
5 #include <stdlib.h>
6 #include <string.h>
7
8 static void
9 sighandler (int signo, siginfo_t* si, void* uc)
10 {
11 throw (5);
12 }
13
14 struct S { void *p1, *p2; };
15
16 struct S v;
17
18 __attribute__ ((noinline))
19 int
20 dosegv ()
21 {
22 struct S *p = 0;
23 struct S s __attribute__((unused)) = *p;
24 return 0;
25 }
26
27 int main ()
28 {
29 struct sigaction sa;
30
31 memset (&sa, 0, sizeof sa);
32 sa.sa_sigaction = sighandler;
33 sigaction (SIGSEGV, &sa, NULL);
34 sigaction (SIGBUS, &sa, NULL);
35
36 try {
37 dosegv ();
38 }
39 catch (int x) {
40 return (x != 5);
41 }
42
43 return 1;
44 }