blob: a29ac883d2a302057484b54de2c6742d14c04460 (
plain) (
blame)
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
|
/* $OpenBSD: exceptions.cc,v 1.1 2021/02/20 19:05:28 otto Exp $ */
/*
* Written by Otto Moerbeek <otto@drijf.net> 2021 Public Domain
*/
#include <string>
#include <iostream>
#include <err.h>
#include <pthread.h>
void
a()
{
try {
throw std::string("foo");
}
catch (const std::string& ex) {
if (ex != "foo")
errx(1, "foo");
}
}
void
b()
{
a();
}
void *
c(void *)
{
b();
return nullptr;
}
#define N 100
int
main()
{
int i;
pthread_t p[N];
for (i = 0; i < N; i++)
if (pthread_create(&p[i], nullptr, c, nullptr) != 0)
err(1, nullptr);
for (i = 0; i < N; i++)
if (pthread_join(p[i], nullptr) != 0)
err(1, nullptr);
std::cout << ".";
return 0;
}
|