Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / vsnprintf.cpp
blob4eb9b24770f5d32f2802d849d92b4098d2353fff
1 // Test that the common part implementation of *printf interceptors does not
2 // cause negative-size-param false positives.
4 // RUN: %clangxx -O2 %s -o %t
5 // RUN: %env_tool_opts=check_printf=1 %run %t 2>&1
7 // FIXME: The maximum supported allocation size is too platform-specific:
8 // REQUIRES: x86_64-target-arch
10 // FIXME: printf is not intercepted on Windows yet.
11 // UNSUPPORTED: target={{.*windows-msvc.*}}
13 #include <stdarg.h>
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <string.h>
18 void write(char *buf, int buf_size, const char *fmt, ...) {
19 va_list args;
20 va_start(args, fmt);
21 vsnprintf(buf, buf_size, fmt, args);
22 va_end(args);
25 int main() {
26 char buffer[100];
27 const size_t kStrSize = 1UL << 31;
28 char *x = (char *)malloc(kStrSize);
29 memset(x, '=', kStrSize - 1);
30 x[kStrSize - 1] = 0;
31 write(buffer, 100, "%s\n", x);
32 free(x);
33 return 0;