News for hackers. Stuff that matters.
Re:C++17 constexpr everything, or as much as the compiler can by minipci1321 on Thursday December 28, 2017 @03:40PM (#16024735)
Certain things, when used in a routine, make computation impossible at compile time. If the routine is marked with 'constexpr', the compiler will verify that.
Re:C++17 constexpr everything, or as much as the compiler can by mehrdadn on Thursday December 28, 2017 @04:31PM (#16025044)
Couldn't it already do the exact same thing without constexpr? (And shouldn't it have already done that when optimizing? In fact for simpler expressions compilers already do this, right?) How does specifying constexpr help?
Re:C++17 constexpr everything, or as much as the compiler can by minipci1321 on Thursday December 28, 2017 @04:42PM (#16025136)
But I think you nailed it -- the compiler doesn't have to signal optimization "failures" back to the developer, but it has to for the constexpr case. It is not that the constexpr routine can be used at compile time, it is that it must be useable at compile time.
Re:C++17 constexpr everything, or as much as the compiler can by mehrdadn on Thursday December 28, 2017 @04:57PM (#16025253)
> But I think you nailed it -- the compiler doesn't have to signal optimization "failures" back to the developer, but it has to for the constexpr case.

Is this true? Where do you see Clang emit a diagnostic in the example in the given article? (https://godbolt.org/g/HKcPFT)

Re:C++17 constexpr everything, or as much as the compiler can by minipci1321 on Thursday December 28, 2017 @05:58PM (#16025824)
You seem to be right -- at least "no diagnostics required" is mentioned a few times in $10.1.5 of N4700. To be honest, my comment is not from the article in the example, but from my own experience, and that is mostly with GCC 7.2.