Consider the following code:
#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 compiles it successfully, but MSVC gives the following error:
error C7595: 'ClassT::GetSize': call to immediate function is not a constant expression
Am I missing something? Or is it really an MSVC bug?
Compilers version: x86-64 gcc 10.2
and x64 msvc v19.28
. (Link to godbolt)