Wen*_*ell 7 c++ variadic-templates c++11 clang++
以下代码剪切产生错误消息和随后的clang 5.0.0和当前主分支的段错误.它适用于任何符合c ++ 11标准的g ++.
#include <initializer_list>
template <typename... T> struct B {};
template <typename T> struct gf {};
template <typename... A> B<A...> make_B(std::initializer_list<gf<A...>> const &V) { return {}; }
int main() {
auto x = gf<int>{};
auto b = make_B<int>({x, x, x}); // clang segfault
//auto b = make_B({x, x, x}); // ok
}
Run Code Online (Sandbox Code Playgroud)
错误消息显示
test.cpp:5:26: error: too many template arguments for class template 'gf'
template <typename... A> B<A...> make_B(std::initializer_list<gf<A...>> const &V) { return {}; }
^
test.cpp:9:12: note: in instantiation of function template specialization 'make_B<int>'
requested here
auto b = make_B<int>({x, x, x}); // clang crash
^
test.cpp:4:30: note: template is declared here
template <typename T> struct gf {};
Run Code Online (Sandbox Code Playgroud)
为什么clang在这里报告错误?gf
在调用中推导出的模板参数的数量make_B<int>
应为1.
关于错误消息之后的段错误,我现在已经提交了错误报告
归档时间: |
|
查看次数: |
167 次 |
最近记录: |