1*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 %s -o %t && not %run %t >%t.out 2>&1 2*7c3d14c8STreehugger Robot // RUN: FileCheck %s < %t.out 3*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -fsanitize-memory-track-origins -O2 %s -o %t && not %run %t >%t.out 2>&1 4*7c3d14c8STreehugger Robot // RUN: FileCheck %s < %t.out 5*7c3d14c8STreehugger Robot 6*7c3d14c8STreehugger Robot // This test relies on realloc from 100 to 101 being done in-place. 7*7c3d14c8STreehugger Robot 8*7c3d14c8STreehugger Robot #include <stdlib.h> main(int argc,char ** argv)9*7c3d14c8STreehugger Robotint main(int argc, char **argv) { 10*7c3d14c8STreehugger Robot char *p = (char *)malloc(100); 11*7c3d14c8STreehugger Robot p = (char *)realloc(p, 101); 12*7c3d14c8STreehugger Robot char x = p[100]; 13*7c3d14c8STreehugger Robot free(p); 14*7c3d14c8STreehugger Robot return x; 15*7c3d14c8STreehugger Robot // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value 16*7c3d14c8STreehugger Robot // CHECK: {{#0 0x.* in main .*realloc-origin.cc:}}[[@LINE-2]] 17*7c3d14c8STreehugger Robot 18*7c3d14c8STreehugger Robot // CHECK: Uninitialized value was created by a heap allocation 19*7c3d14c8STreehugger Robot // CHECK: {{#0 0x.* in .*realloc}} 20*7c3d14c8STreehugger Robot // CHECK: {{#1 0x.* in main .*realloc-origin.cc:}}[[@LINE-9]] 21*7c3d14c8STreehugger Robot } 22