[英]auto template parameters: g++ 7.3 vs clang++ 6.0 : Which compiler is correct?
Two compilers produce different results for this code example. 对于此代码示例,两个编译器产生不同的结果。 Clang generates two different types. lang产生两种不同的类型。 G++ uses same type for fu
and fi
. G ++对fu
和fi
使用相同的类型。 Which one is standard compliant? 哪一个符合标准?
#include <iostream>
template< auto IVAL>
struct foo {
decltype(IVAL) x = -IVAL;
};
int main()
{
foo<10u> fu;
foo<10> fi;
std::cout << fi.x << " " << fu.x << '\n';
return 0;
}
g++-7.3 output: g ++-7.3输出:
4294967286 4294967286 4294967286 4294967286
clang-6.0 output: clang-6.0输出:
-10 4294967286 -10 4294967286
gcc is wrong here, these are clearly two distinct types. gcc在这里是错误的,显然这是两种不同的类型。
And to confirm - this bug is fixed in gcc 8.0.1 并确认-此错误已在gcc 8.0.1中修复
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.