Следующая программа компилируется с GCC 5.2, но не с clang 3.6:
constexpr bool flag();
template <bool b = flag()>
constexpr bool test()
{
return b;
}
int main()
{
}
Сообщение об ошибке, которое я получаю с clang:
main.cpp:3:20: error: non-type template argument is not a constant expression
template <bool b = flag()>
^~~~~~
main.cpp:3:20: note: undefined function 'flag' cannot be used in a constant expression
main.cpp:1:16: note: declared here
constexpr bool flag();
^
main.cpp:4:16: error: no return statement in constexpr function
constexpr bool test()
^
Мой вопрос: кто прав? Или, другими словами: Является ли программа плохо сформированной?