https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111050

--- Comment #5 from TC <rs2740 at gmail dot com> ---
Minimal example:

$ cat lib1.cpp
#include <unordered_set>
#include <string>

static std::unordered_set<std::string> set;

void del(const std::string& s) {
    set.erase(s);
}

$ cat lib2.cpp
#include <unordered_set>
#include <string>

static std::unordered_set<std::string> set;

void add(const std::string& s) {
    set.emplace(s);
}

const std::string& get(const std::string& s) {
    return *set.find(s);
}

$ cat main.cpp

#include <string>

void add(const std::string&);
void del(const std::string&);
const std::string& get(const std::string&);

int main() {
    add("foo");
    del("bar");
    (void) get("foo").size();
}

$ g++-10 -std=c++17 lib1.cpp -c -o lib1.o
$ g++-13 -std=c++17 lib2.cpp -c -o lib2.o
$ g++-13 -std=c++17 main.cpp lib1.o lib2.o -o test
$ ./test
Segmentation fault (core dumped)

Reply via email to