GCC cannot evaluate some expression as constant. Klang, however, is pleased with him.
constexpr int foo(const int * array) { if (array == nullptr)
Also does not work:
constexpr int foobar() { int array[100] = {}; int *ar = array; if (ar == nullptr)
Same:
constexpr int foo2() { int *a = nullptr; if (a == nullptr)
Living example
I mean, a comparison with nullptr should be something other than a comparison with another random address.
Could you say: is this a mistake or a question of interpretation? It's hard for me to write the same code for both compilers ...
This error occurs for GCC 5.0 to 5.4. In GCC 6+, only foobar() does not compile.
source share