20 static volatile uint64_t
sink;
24 __asm__ __volatile__(
"" :::
"memory");
sink ^= (uint64_t)i;
26 extern "C" __attribute__((noinline))
void ctorthrow_catch_marker(
int i) {
27 __asm__ __volatile__(
"" :::
"memory");
sink ^= (uint64_t)i << 8;
38 B(uint8_t* s,
bool doThrow) :
slot(s) {
40 if (doThrow)
throw std::runtime_error(
"boom");
57 int main(
int argc,
char** argv) {
58 (void)argc; (void)argv;
60 for (
int i = 0; i <
ITERS; ++i) {
61 uint8_t* base = &
buf[i * 4];
63 ctorthrow_try_marker(i);
66 }
catch (
const std::exception&) {
67 ctorthrow_catch_marker(i);
78 for (
int i = 0; i <
ITERS; ++i) {
79 uint8_t* p = &
buf[i * 4];
80 if (p[0] == 0xFF && p[1] == 0xCC && p[2] == 0x22 && p[3] == 0) ++ok;
83 fprintf(stderr,
"exc_ctor_throw: caught=%d ok_pattern=%d/%d sink=%llx\n",
84 caught, ok,
ITERS, (
unsigned long long)
sink);
85 return (caught ==
ITERS && ok ==
ITERS) ? 0 : 1;
int main(int argc, char **argv)
static uint8_t buf[ITERS *4]
__attribute__((noinline)) void ctorthrow_try_marker(int i)
static volatile uint64_t sink
B(uint8_t *s, bool doThrow)