MSVC 中的 type_info 编译器错误?

Nik*_*dig 7 c++ templates types clang visual-c++

所以我有这个代码:

#include <typeinfo>
#include <iostream>

void thing(char thing[2], int thing2) {

}

void thing2(char* thing, int thing2) {

}

template <typename T, typename U>
struct are_types_same {
    constexpr operator bool() const noexcept { return false; }
};

template <typename T>
struct are_types_same<T, T> {
    constexpr operator bool() const noexcept { return true; }
};

int main() {
    const std::type_info& info = typeid(thing);
    const std::type_info& info2 = typeid(thing2);

    std::cout << "typeid: " << (info == info2) << '\n';
    std::cout << "are_types_same: " << are_types_same<decltype(thing), decltype(thing2)>{} << '\n';
}
Run Code Online (Sandbox Code Playgroud)

我惊讶地发现,当比较 MSVC(x86,v19.32)中类型的类型信息时,比较结果为 false,而基于模板专业化的比较结果为 true。我在 clang (x86-64, v14.0.0) 上尝试过,结果都是 true。

我听说 MSVC 在模板等较新的 C++ 方面表现很糟糕,这是这里发生的情况吗?这算不算编译器错误?值得在某个地方举报吗?

use*_*570 3

这算不算编译器错误?

是的,这似乎是一个msvc 错误,已报告为:

type_info比较函数时产生不正确的结果

这两个函数确实具有相同的类型,并且检查info == info2应该产生true