【发布时间】: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 <variant> header if you want to look at it.
在等待官方修复时,我按照 Clang 的建议进行操作,并将 noexcept 添加到标题中。
它似乎到目前为止工作。
此解决方案会导致任何问题吗?我应该做点别的吗?
如果您知道它是 libstdc++ 错误还是 Clang 错误,则可以加分。
【问题讨论】:
标签: c++ clang clang++ libstdc++