I'm compiling a working and well-tested C library. This fails:
gretl_matrix_block *gretl_matrix_block_new (gretl_matrix **pm, ...) {
va_list ap;
va_start(ap, pm);
va_arg(ap, int);
Results in
Error: template `va_arg` is not callable using argument types `!(int)(__va_list_tag*)`
#defines(521): Candidate is: `va_arg(__MP314, __MP315)(__MP314 v, __MP315 l)`
Comment #1 by lance — 2024-03-27T17:21:52Z
Here's a simpler program that shows the bug. Compiles with gcc but not dmd:
#include <stdarg.h>
#include <stddef.h>
void foo(double * pm, ...) {
va_list ap;
double * targ;
va_start(ap, pm);
for (int i=1; ; i++) {
va_arg(ap, int);
targ = va_arg(ap, double*);
if (targ == NULL) {
break;
}
}
va_end(ap);
}
DMD output: va.c(9): Error: template `va_arg` is not callable using argument types `!(int)(__va_list_tag*)`
#defines(110): Candidate is: `va_arg(__MP23, __MP24)(__MP23 v, __MP24 l)`
va.c(10): Error: template `va_arg` is not callable using argument types `!(double*)(__va_list_tag*)`
#defines(110): Candidate is: `va_arg(__MP23, __MP24)(__MP23 v, __MP24 l)`
Comment #2 by robert.schadek — 2024-12-13T19:34:05Z