2 ms·
"Modern compilers" still fail at: const int bla = 23; const int blub[bla] = { 0 }; (see: https://www.godbolt.org/z/hjessMhGK https://www.godbolt.org/z
by flohofwoe 4y ago
"Modern compilers" still fail at:
const int bla = 23;
const int blub[bla] = { 0 };
(see: https://www.godbolt.org/z/hjessMhGK https://www.godbolt.org/z/hjessMhGK)
Isn't this exactly what constexpr is supposed to solve?
- quelsolaar 4y agoIf so why not fix const? Why add a whole new keyword? Why complicate the language?
- flohofwoe 4y agoDon't know, you're in WG14, not me :D Maybe 'const' can't be fixed without breaking existing source code? I don't really have a problem with adding a new keyword for 'actually const', maybe calling it 'constexpr' means C++ people have wrong expectations though, dunno. For me, having constexpr being explicit about only accepting actual constant expressions, and creating an error otherwise (instead of silently falling back to a 'runtime expression') is fine, but the existing keyword 'const' has an entirely different meaning, there's just an unfortunate naming collision with other languages where const means 'compile time constant'.