Si consideri il codice seguente, che utilizza una funzione con argomenti variabili:Clang: deduzione modello fallito 'doppio' vs '<double>'
#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);
}
compilazione questo con g ++ 4.7.3 funziona bene, e in esecuzione produce 1024.0
come previsto.
compilazione utilizzando 14.0.2 ICPC si blocca ...
templ.cc(21): internal error: assertion failed: lower_expr: bad kind (shared/cfe/edgcpfe/lower_il.c, line 18582)
run_func(f, &value);
^
compilazione con clangore 3.5.0-1 ha pronunciato la seguente messaggio di errore:
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) {
^
Questo è un bug, o dovrebbe hai g ++ non compilato questo?
Perché clang deducendo questi tipi "in conflitto" di double
e <double>
, è <double>
destinato a rappresentare un arglist decompresso, ad esempio?
Aggiornamento icpc 14.0.3 non si arresta in modo anomalo e il programma viene compilato ed eseguito correttamente.
See DPD200244439 a Intel® Composer XE 2013 SP1 Compilers Fixes List
L'ultima domanda che potresti rispondere spendendo run_func (f, & value, & value) ... che risulta in che non penso sia corretto ... potresti provare con un altro recente clang da svn, puzza di bug –
PlasmaHH
Poiché sostituire il 'template using' con il tipo nativo fa scomparire il problema, sembra proprio un bug. –
@PlasmaHH Ho provato la versione clang 3.5.0 (trunk 208562), lo stesso problema! – WaelJ