Clang:模板演绎失败'双'与'<双>'

Wae*_*elJ 10 c++ templates clang function-templates c++11

请考虑以下代码,该代码使用带有可变参数的函数:

#include <iostream>

// Typedef function type
template<typename... Output>
using Func = void(Output*...);

// Function runner
template<typename... Output>
void run_func(Func<Output...>& func, Output*... output) {
  for (int i=0 ; i < 10 ; ++i) {
    func(output...);
  }
}

void f(double* d) {
  *d *= 2;
};

int main() {
  double value = 1.0;
  run_func(f, &value);
  printf("%f\n", value);
}
Run Code Online (Sandbox Code Playgroud)

用g ++ 4.7.3编译它可以正常工作,并且运行1024.0按预期生成.

使用icpc 14.0.2进行编译会使其崩溃...

templ.cc(21): internal error: assertion failed: lower_expr: bad kind (shared/cfe/edgcpfe/lower_il.c, line 18582)

    run_func(f, &value);
    ^
Run Code Online (Sandbox Code Playgroud)

使用clang 3.5.0-1进行编译会出现以下错误消息:

templ.cc:21:3: error: no matching function for call to 'run_func'
  run_func(f, &value);
  ^~~~~~~~
templ.cc:9:6: note: candidate template ignored: deduced conflicting types for parameter 'Output' ('double' vs. <double>)
void run_func(Func<Output...>& func, Output*... output) {
     ^
Run Code Online (Sandbox Code Playgroud)

这是一个错误,还是应该让g ++不编译?

为什么铛演绎这些"冲突的"类型的double<double>,是<double>指代表例如解压的arglist?

更新 icpc 14.0.3不会崩溃,程序编译并正确运行.

请参阅英特尔 ®ComposerXE 2013 SP1编译器修复列表中的 DPD200244439

Wae*_*elJ 1

经过上面的讨论,看来这确实是clang的一个bug。

正如gha.st所指出的,跳过template using并使用本机函数类型直接有效:

void run_func(void (&func)(Output*...), Output*... output) {
Run Code Online (Sandbox Code Playgroud)

我已经在这里提交了一个针对此的错误。