I seem to have found something that Clang and GCC disagree on. Here's the code:
int main() {
if constexpr (2) {}
}
This successfully compiles with GCC 7.4.0, but it fails with Clang 7.0.0 with this error message:
test.cpp:3:17: error: constexpr if condition evaluates to 2, which cannot be narrowed to type 'bool'
[-Wc++11-narrowing]
if constexpr (2) {}
^
1 error generated.
cppreference doesn't seem to mention "narrowing", so this seems like a Clang bug, but I'm not entirely certain. If this is a bug with either compiler, has it already been reported?
question from:https://stackoverflow.com/questions/54899466/constexpr-if-with-a-non-bool-condition