且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C ++ 11:GCC 4.8静态thread_local std :: unique_ptr未定义引用

更新时间:2023-11-13 13:44:58

我通过在Yay.hpp中为Yay定义了什么都不做的ctor进行了实验:

I experimented with this by defining a do-nothing ctor for Yay in Yay.hpp:


- Yay() = delete;
+ Yay() {}

当我这样做时,错误消息变为:

When I did that, the error message became:


/tmp/cc8gDxIg.o: In function `TLS wrapper function for Yay::yay':
main.cpp:(.text._ZTWN3Yay3yayE[_ZTWN3Yay3yayE]+0x5): undefined reference to `TLS init function for Yay::yay'

这导致我发现 GCC错误55800 .该错误存在于GCC 4.8.2之前的版本中,并已在4.8.3和4.9中修复.在讨论线程中,我在重复的 GCC错误59364 中找到了使不回端口修复程序.因此,在升级到4.9之前,您的汇编器黑客似乎是唯一可用的解决方案.

That led me to GCC bug 55800. The bug exists in GCC versions up through 4.8.2, and is fixed in 4.8.3 and 4.9. In discussion threads I found on duplicate GCC bug 59364, the decision has been made not to back port the fix. Therefore, your assembler hack appears to be the only solution available until you move to 4.9.