4 ms·
> Hey, by all means fix clang and gcc so that my example no longer requires a runtime call to mul(). They can just pretend every inline function has constexpr
by dataflow 5y ago
> Hey, by all means fix clang and gcc so that my example no longer requires a runtime call to mul().
They can just pretend every inline function has constexpr in front of it, and fall back to compiling them if they fail to evaluate it as constexpr. The constexpr doesn't tell the compiler anything it didn't already know or have to verify anyway. And bear in mind much of the standard library already has constexpr in front of it (and that's a pretty strong signal that it should've been implicit IMO). I don't know Clang or GCC's codebases to know exactly what to modify off the top of my head, but I'm pretty sure adding an extra 'constexpr' internally in the front-end would be utterly trivial as far as compilers go. No need for any optimizations to get involved (and it's important to understand this).