奇怪的stdlib(memory.h)问题,make_shared专属于xcode apple clang

Strange stdlib(memory.h) issues with make_shared exclusive to xcode apple clang

本文关键字:shared make 属于 clang apple xcode 问题 stdlib memory      更新时间:2023-10-16

我有奇怪的问题,只出现在OSX上。(它可以在windows上使用visual studio和linux上使用gcc和clang)/在我的代码中,我有这样的东西:

std::shared_ptr<mythread> ptr = std::make_shared<mythread>(name)

mythread派生自一个没有except(false)析构函数和一些基本结构的类。

apple clang抱怨:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3686:7: error: exception specification of overriding function is more lax than base version class __shared_ptr_emplace

跳过实例化/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3616:13: note: overridden virtual function is here virtual ~__shared_weak_count();

如何修复这个错误,为什么它出现(仅在osx上)?我在clang中发现了一些类似的bug,但它们应该在2011年被修复。

显然由于某种原因,它不喜欢在父类的析构函数中使用noexcept(false)。无法用连贯的方式来表达。