summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/msan/lit_tests/c-strdup.c
blob: 7772f0f307b7226f6d47558abafaa1774a735b89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// RUN: %clang_msan -m64 -O0 %s -o %t && %t >%t.out 2>&1
// RUN: %clang_msan -m64 -O1 %s -o %t && %t >%t.out 2>&1
// RUN: %clang_msan -m64 -O2 %s -o %t && %t >%t.out 2>&1
// RUN: %clang_msan -m64 -O3 %s -o %t && %t >%t.out 2>&1

// Test that strdup in C programs is intercepted.
// GLibC headers translate strdup to __strdup at -O1 and higher.

#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv) {
  char buf[] = "abc";
  char *p = strdup(buf);
  if (*p)
    exit(0);
  return 0;
}
OpenPOWER on IntegriCloud