【问题标题】:How to fix lib libstdc++'s `std::variant` (from GCC 9.1) not working with Clang 8?如何修复 lib libstdc++ 的 `std::variant`(来自 GCC 9.1)不适用于 Clang 8?
【发布时间】:2019-06-06 21:30:59
【问题描述】:

MSYS2 的 GCC 包最近更新到 9.1,但 Clang 不喜欢它附带的新 <variant> libstdc++ 标头。

编译以下简单程序时:

#include <variant>

int main()
{
    std::variant<int, float> x;
}

我明白了:

# clang++ -std=c++17 foo.cpp

In file included from foo.cpp:1:
Z:\...\msys2\mingw64\include\c++\9.1.0\variant:1559:55: error: '__get' is missing exception specification 'noexcept'
        friend constexpr decltype(auto) __detail::__variant::__get(_Vp&& __v);
                                                             ^
foo.cpp:5:30: note: in instantiation of template class 'std::variant<int, float>' requested here
    std::variant<int, float> x;
                             ^
Z:\...\msys2\mingw64\include\c++\9.1.0\variant:263:5: note: previous declaration is here
    __get(_Variant&& __v) noexcept
    ^
1 error generated.

Here is the complete &lt;variant&gt; header if you want to look at it.

在等待官方修复时,我按照 Clang 的建议进行操作,并将 noexcept 添加到标题中。

似乎到目前为止工作。

此解决方案会导致任何问题吗?我应该做点别的吗?

如果您知道它是 libstdc++ 错误还是 Clang 错误,则可以加分。

【问题讨论】:

    标签: c++ clang clang++ libstdc++


    【解决方案1】:

    修复是正确的。这是一个 libstdc++ 错误,请参阅 https://bugs.llvm.org/show_bug.cgi?id=41863https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90397

    【讨论】:

      猜你喜欢
      • 2023-03-03
      • 2017-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-26
      • 2014-12-21
      • 2019-05-10
      • 2015-10-15
      相关资源
      最近更新 更多