summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/asan/pr81021.C
blob: 4904f19bf844518a14707978a24a380a711806ca (plain)
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
// { dg-do run }

#include <string>

struct ConfigFile {
    ConfigFile(std::string filename, std::string delimiter) { throw "error"; }
    ConfigFile(std::string filename) {}
};

struct Configuration {
    ConfigFile _configFile;

    Configuration(const std::string &root, const char *baseName)
        : _configFile(root + baseName, "=") { }
    Configuration(const std::string &root, const char *a, const char *b)
        : _configFile(root + a + b) { }
};


void test() {
    std::string root("etc");
    try {
        Configuration config(root, "notthere");
    }
    catch (...) {
        // exception is thrown, caught here and ignored...
    }
    Configuration config(root, "a", "b"); // ASAN error during constructor here
}

int main(int argc, const char *argv[]) {
    test();
}