[Bug libstdc++/103629] [11/12/13 Regression] wrong-code when mixing mutex with visibility=hidden
malat at debian dot org
gcc-bugzilla@gcc.gnu.org
Wed Aug 24 12:28:40 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
--- Comment #25 from Mathieu Malaterre <malat at debian dot org> ---
Looks like there is an easy fix (work-around?):
% cat Tree.h
#pragma once
#include <memory>
#include <mutex>
class
#ifdef VIS
__attribute__((visibility("default")))
#endif
Tree {
public:
static const std::string treeType() {
static std::once_flag once;
std::call_once(once, []() {
std::printf("%p\n", &sTreeTypeName);
sTreeTypeName.reset(new std::string());
});
std::printf("%p\n", &sTreeTypeName);
if (!sTreeTypeName)
throw "uhoh";
return *sTreeTypeName;
}
private:
static std::unique_ptr<const std::string> sTreeTypeName;
};
std::unique_ptr<const std::string> Tree::sTreeTypeName;
More information about the Gcc-bugs
mailing list