【发布时间】:2020-11-29 02:43:48
【问题描述】:
template <bool>
void f() { }
int main ()
{
constexpr long long int num = 5;
f<num & 4>(); // bitwise & is intended
return 0;
}
gcc 9 有问题:
error: no matching function for call to 'f<(5 & 4)>()'
error: narrowing conversion of '4' from 'long long int' to 'bool' [-Wnarrowing]
clang 有问题:
error: no matching function for call to 'f'
gcc 8 和 msvc 编译没有错误。
谁是正确的?我认为错误是正确的,但想确认一下。
【问题讨论】:
标签: c++ c++11 templates language-lawyer non-type