int d = 1;
constexpr void add()
{
d++;
}
int main()
{
}
GCC 7.1 will report errors below. The error message is very clear. The problem is that I don't see any explicit explanations in constexpr to describe it's illegal.
Can someone explain which rules defined in spec this case violate?
main.cpp: In function 'constexpr void add()': main.cpp:8:1: error: the value of 'd' is not usable in a constant expression } ^ main.cpp:4:5: note: 'int d' is not const int d = 1; ^
Aucun commentaire:
Enregistrer un commentaire