1// RUN: %clangxx_asan -O0 %s -o %t && %run %t 2>&1 | FileCheck %s
2// RUN: %clangxx_asan -O3 %s -o %t && %run %t 2>&1 | FileCheck %s
3
4#ifndef _GNU_SOURCE
5#define _GNU_SOURCE
6#endif
7
8#include <stdio.h>
9#include <stdlib.h>
10
11int main(int argc, char **argv) {
12 char *p;
13 int res = asprintf(ptr: &p, fmt: "%d", argc);
14 fprintf(stderr, format: "x%d %sx\n", res, p);
15 // CHECK: x1 1x
16 free(ptr: p);
17 fprintf(stderr, format: "DONE\n");
18 // CHECK: DONE
19 return 0;
20}
21

source code of compiler-rt/test/asan/TestCases/Posix/asprintf.cpp