blob: fd009d1d4fe84c0cf089d40fbc63811da4db301c [file] [log] [blame]
Stephen Hines2d1fdb22014-05-28 23:58:16 -07001// RUN: %clang_asan -O2 %s -o %t
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -08002// RUN: %env_asan_opts=check_printf=1 %run %t 2>&1 | FileCheck %s
3// RUN: %env_asan_opts=check_printf=0 %run %t 2>&1 | FileCheck %s
Stephen Hines2d1fdb22014-05-28 23:58:16 -07004// RUN: %run %t 2>&1 | FileCheck %s
5
6#include <stdio.h>
Stephen Hines6a211c52014-07-21 00:49:56 -07007#if defined(_WIN32)
8# define snprintf _snprintf
9#endif
10
Stephen Hines2d1fdb22014-05-28 23:58:16 -070011int main() {
12 volatile char c = '0';
13 volatile int x = 12;
14 volatile float f = 1.239;
15 volatile char s[] = "34";
16 // Check that printf works fine under Asan.
17 printf("%c %d %.3f %s\n", c, x, f, s);
18 // CHECK: 0 12 1.239 34
19 // Check that snprintf works fine under Asan.
20 char buf[4];
21 snprintf(buf, 1000, "qwe");
22 printf("%s\n", buf);
23 // CHECK: qwe
24 return 0;
25}