Example:
int main(int argc, char**)
{
constexpr int a = argc * 0;
(void)a;
constexpr int b = argc - argc;
(void)b;
return 0;
}
arg is not a constant expression, but the compiler is still able to compute the results of a and b in compile time (i.e. 0) in both cases.
g++ accepts the code above, while clang and MSVC14 reject it.
Does the standard allows the compiler being as smart as g++ with regard to constexpr?
Aucun commentaire:
Enregistrer un commentaire