1// RUN: %clang_msan -O0 %s -o %t && %run %t >%t.out 2>&1
2// RUN: %clang_msan -O1 %s -o %t && %run %t >%t.out 2>&1
3// RUN: %clang_msan -O2 %s -o %t && %run %t >%t.out 2>&1
4// RUN: %clang_msan -O3 %s -o %t && %run %t >%t.out 2>&1
5
6// Test that strdup in C programs is intercepted.
7// GLibC headers translate strdup to __strdup at -O1 and higher.
8
9#include <stdlib.h>
10#include <string.h>
11int main(int argc, char **argv) {
12 char buf[] = "abc";
13 char *p = strdup(s: buf);
14 if (*p)
15 exit(status: 0);
16 return 0;
17}
18

source code of compiler-rt/test/msan/c-strdup.c