www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23409] New: ImportC: multiple usages of va_list produces


          Issue ID: 23409
           Summary: ImportC: multiple usages of va_list produces garbage
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Mac OS X
            Status: NEW
          Keywords: ImportC
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dave287091 gmail.com

#include <stdio.h>
#include <stdarg.h>

void printf10(const char* fmt, ...){
    for(int i = 0; i < 10; i++){
        va_list args;
        va_start(args, fmt);
        vprintf(fmt, args);

int main(){
    printf10("Hello %s\n", "world");
    return 0;

Example output of the above:

$ ./vap
Hello world
Hello �Ƚ
Hello �Ƚ
Segmentation fault: 11

Segfault occurs within a call to strlen (as it is strlen-ing garbage).

Oct 12 2022