[Issue 23409] ImportC: multiple usages of va_list produces garbage

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Oct 12 22:12:11 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=23409

--- Comment #2 from dave287091 at gmail.com ---
(In reply to dave287091 from comment #1)
> The D version also seg faults, so maybe D’s implementation of stdarg is
> buggy?
> 
> import core.stdc.stdarg;
> import core.stdc.stdio;
> 
> void printf10(const(char)* fmt, ...){
>     for(int i = 0; i < 10; i++){
>         va_list args;
>         va_start(args, fmt);
>         vprintf(fmt, args);
>         va_end(args);
>     }
> }
> 
> int main(){
>     printf10("Hello %s\n".ptr, "world".ptr);
>     return 0;
> }

Forgot the extern(C) on printf10, but it still is buggy:

$ ./vap
Hello world
Hello 
Segmentation fault: 11

--


More information about the Digitalmars-d-bugs mailing list