27 lines · cpp
1// RUN: %clangxx_msan -O0 -g %s -o %t && %run %t2// RUN: %clangxx_msan -O0 -g -DUNINIT %s -o %t && not %run %t 2>&1 | FileCheck %s3 4#include <assert.h>5#include <time.h>6 7#include <sanitizer/msan_interface.h>8 9int main(void) {10 struct tm tm;11 tm.tm_year = 2014;12 tm.tm_mon = 3;13 tm.tm_mday = 28;14#ifndef UNINIT15 tm.tm_hour = 13;16#endif17 tm.tm_min = 4;18 tm.tm_sec = 42;19 tm.tm_isdst = -1;20 time_t t = mktime(&tm);21 // CHECK: MemorySanitizer: use-of-uninitialized-value22 // CHECK: in main{{.*}}mktime.cpp:[[@LINE-2]]23 assert(t != -1);24 assert(__msan_test_shadow(&tm, sizeof(tm)) == -1);25 return 0;26}27