aboutsummaryrefslogtreecommitdiff
path: root/tests/i/extern-cc-runtime/runtime.cc
blob: be4e4c3729515fee40c43f2906ba95e3573596d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

#include <cstdio>
#include <string>
#include <stdexcept>
extern "C" int string_length() {
    std::string text(4096, 'x');
    text += std::to_string(123);
    return static_cast<int>(text.size());
}
extern "C" void string_throw() {
    try { throw std::invalid_argument("string failure"); }
    catch (const std::exception &e) {
        std::fprintf(stderr, "%s\n", e.what());
        if (std::string(e.what()) == "string failure") throw;
    }
}