TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Unique_ptr difference between libstdc++ and Libc++ crashes your application

55 点作者 ognarb超过 4 年前

3 条评论

jeffbee超过 4 年前
The correct headline here is “KDE defect is silent with libstdc++, fatal with libc++”.
评论 #26206208 未加载
Someone超过 4 年前
So, is either of these not standard-compliant? I Looked at <a href="https:&#x2F;&#x2F;en.cppreference.com&#x2F;w&#x2F;cpp&#x2F;memory&#x2F;unique_ptr" rel="nofollow">https:&#x2F;&#x2F;en.cppreference.com&#x2F;w&#x2F;cpp&#x2F;memory&#x2F;unique_ptr</a> (yes, I know that’s not the standard, but _I_ trust it to follow it close enough), and couldn’t find evidence for it.<p>I suspect, however, that the standards committee, knowing of this discrepancy, would go with libc++. They explicitly said that <i>reset</i> has to update the pointer before deleting the old object (<a href="https:&#x2F;&#x2F;en.cppreference.com&#x2F;w&#x2F;cpp&#x2F;memory&#x2F;unique_ptr&#x2F;reset" rel="nofollow">https:&#x2F;&#x2F;en.cppreference.com&#x2F;w&#x2F;cpp&#x2F;memory&#x2F;unique_ptr&#x2F;reset</a>), so one would think they don’t want <i>get()</i> to return the pointer while the unique_pointer destructor is running.<p>On the other hand, none of that matters in the case if multiple threads or out-of-order CPUs (or do I read <a href="https:&#x2F;&#x2F;en.cppreference.com&#x2F;w&#x2F;cpp&#x2F;memory&#x2F;unique_ptr&#x2F;reset" rel="nofollow">https:&#x2F;&#x2F;en.cppreference.com&#x2F;w&#x2F;cpp&#x2F;memory&#x2F;unique_ptr&#x2F;reset</a> incorrectly, and is some sort of fence implied there?)
评论 #26206605 未加载
评论 #26206580 未加载
eklitzke超过 4 年前
I&#x27;m not sure what the author expected when trying to link code that mixes uses of libstdc++ and libc++: there are not ABI compatible in any way. If you need ABI compatibility between different compilers you must write C.
评论 #26206068 未加载
评论 #26206058 未加载
评论 #26206090 未加载
评论 #26206192 未加载
评论 #26205978 未加载