June 03, 2023
https://issues.dlang.org/show_bug.cgi?id=23958

          Issue ID: 23958
           Summary: ImportC: undefined identifier `__builtin__sprintf_chk`
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: mail@tomaskral.sk

Compiling the following C code on macOS:

#include <stdio.h>

int main() {
  char buf[8];
  sprintf(buf, "%d", 123);
}


fails with an error:

main.c(5): Error: undefined identifier `__builtin___sprintf_chk`

Running the same C code through the preprocessor shows that `sprintf` is replaced with:

__builtin___sprintf_chk (buf, 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0),
"%d", 123);

I'm using macOS 12.6, DMD v2.104.0

--