GCC与微软创业投资公司(非工作)的不同求职行为 [英] Different behavior of consteval in GCC and MSVC (not work)
本文介绍了GCC与微软创业投资公司(非工作)的不同求职行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
考虑以下代码:
#include <cstdint>
#include <vector>
class ClassT
{
public:
consteval static size_t GetSize()
{
return sizeof(int);
}
void Resize()
{
_Data.resize(GetSize(), 0);
}
std::vector<uint8_t> _Data;
};
int main()
{
ClassT Object;
Object.Resize();
return 0;
}
GCC编译成功,但msvc提示错误:
error C7595: 'ClassT::GetSize': call to immediate function is not a constant expression
我错过了什么吗?或者这真的是MSVC错误?
编译器版本:x86-64 gcc 10.2
和x64 msvc v19.28
。(Link to godbolt)
msvc
这看起来像推荐答案错误。它甚至可能与现有的这个相同-#1224555。
最小示例:
consteval int test() { return 0; }
int main() {
return test(); // error C7595: 'test': call to immediate function is not a constant expression
}
这篇关于GCC与微软创业投资公司(非工作)的不同求职行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文