MSVC 在不知道类型的情况下评估上下文(和错误)
MSVC evaluating context (and erroring) without knowing types
此代码在 MSVC 上编译失败,因为static_assert
失败:
template<class MyType>
struct Test {
static_assert(MyType(5) != MyType(6), "fails");
};
请参阅:https://godbolt.org/z/vUSMHu
任何想法MSVC如何在不知道MyType是什么的情况下评估这一点?
更晦涩难懂:
template<class MyType>
struct Test {
static_assert(MyType(5) == MyType(6), "succeeds");
static_assert(!(MyType(5) == MyType(6)), "fails");
};
请参阅:https://godbolt.org/z/3631tu
实例化它(即给 MyType 一个类型(也无济于事:
template<class MyType>
struct Test {
static_assert(MyType(5) != MyType(6), "still fails");
};
Test<int> variable;
请参阅: https://godbolt.org/z/yxF4h0
或者稍微复杂一点:https://godbolt.org/z/68g6yO
是的,这个奇怪的错误发生在 MSVC 19.10 中,但它在 MSVC 19.14 及更高版本中已经不可重现。演示:https://gcc.godbolt.org/z/635Mxdazd
因此,可以合理地假设它只是一个编译器错误。
相关文章:
- 线程,如果else语句,都是错误的上下文切换后,会发生什么
- 错误"Could not find Boost"(缺少:上下文标头)
- DCMTK 了解"DIMSE 没有有效的演示上下文 ID"错误
- MSVC 在不知道类型的情况下评估上下文(和错误)
- 关于 GetDIBits 和设备上下文的奇怪错误
- 自定义删除器,用于shared_ptr<>给出"无上下文错误"
- Linux/QT-错误创建SSL上下文(错误:140A90C4 ..)
- 分段错误将文本呈现到开罗上下文
- 在spirit parser Action中,在上下文参数上编译boost :: bind(成员函数)上的错误
- OpenGL 上下文创建期间未记录的错误
- 如何修复C#应用程序中调用C++DLL函数时的上下文加载错误
- 带有 QT 错误的 OpenGL:ASSERT:"QOpenGLFunctions::isInitialized(d_ptr)" 。无法创建 OpenGL 上下文
- 当任何子线程导致错误时,上下文切换到主线程
- 带有模板的矢量在打印上下文时在瓦尔格林德中给出错误
- C++上下文错误
- 渲染自定义模型时出现c++Directx 11设备上下文错误
- 此上下文标记中的错误可能会标记错误的位置
- 类声明错误:上下文信息不足,无法确定类型
- 激活上下文生成失败.VC运行时错误
- VS 2013 单元测试不起作用 =设置执行上下文时出现>错误