1 /*	$OpenBSD: exceptions.cc,v 1.2 2021/10/06 12:43:14 bluhm Exp $	*/
2 /*
3  *	Written by Otto Moerbeek <otto@drijf.net> 2021 Public Domain
4  */
5 
6 #include <string>
7 #include <iostream>
8 #include <err.h>
9 #include <pthread.h>
10 
11 void
a()12 a()
13 {
14 	try {
15 		throw std::string("foo");
16 	}
17 	catch (const std::string& ex) {
18 		if (ex != "foo")
19 			errx(1, "foo");
20 	}
21 }
22 
23 void
b()24 b()
25 {
26 	a();
27 }
28 
29 void *
c(void *)30 c(void *)
31 {
32 	b();
33 	return NULL;
34 }
35 
36 #define N 100
37 
38 int
main()39 main()
40 {
41 	int i;
42 	pthread_t p[N];
43 
44 	for (i = 0; i < N; i++)
45 		if (pthread_create(&p[i], NULL, c, NULL) != 0)
46 			err(1, NULL);
47 	for (i = 0; i < N; i++)
48 		if (pthread_join(p[i], NULL) != 0)
49 			err(1, NULL);
50 	std::cout << ".";
51 	return 0;
52 }
53