Bug 24455 – [ImportC] va_arg fails in working C code

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2024-03-27T02:41:46Z
Last change time
2024-12-13T19:34:05Z
Assigned to
No Owner
Creator
Lance Bachmeier
Moved to GitHub: dmd#20423 →

Comments

Comment #0 by lance — 2024-03-27T02:41:46Z
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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20423 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB