4 ms·
C++ is able to do it in constexpr contexts - a constexpr function cannot exhibit UB (else it's a compile error)
by jcelerier 7y ago
C++ is able to do it in constexpr contexts - a constexpr function cannot exhibit UB (else it's a compile error)
- saagarjha 7y agoThis is technically correct, but I believe this is also a very buggy area of the compiler and there are cases where it will accept undefined behavior in a constexpr context: https://shafik.github.io/c++/undefined%20behavior/2019/05/11/explporing_undefined_behavior_using_constexpr.html https://shafik.github.io/c++/undefined%20behavior/2019/05/11...
- jcelerier 7y agoright, but all compilers / interpreters for all languages have bugs.
- saagarjha 7y agoThey do, but I'm just pointing out that trying to use constexpr as the judge of what is defined is generally not a great idea at the moment unless what you're actually trying to do is find some language-lawyer compiler bugs to file.