1*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -O2 %s -o %t && %run %t 2*7c3d14c8STreehugger Robot 3*7c3d14c8STreehugger Robot #include <sanitizer/msan_interface.h> 4*7c3d14c8STreehugger Robot 5*7c3d14c8STreehugger Robot struct S { SS6*7c3d14c8STreehugger Robot S(int a0) : a(a0) {} 7*7c3d14c8STreehugger Robot int a; 8*7c3d14c8STreehugger Robot int b; 9*7c3d14c8STreehugger Robot }; 10*7c3d14c8STreehugger Robot 11*7c3d14c8STreehugger Robot // Here S is passed to FooRun as a 64-bit integer. 12*7c3d14c8STreehugger Robot // This triggers an optimization where 10000 * s.a is transformed into 13*7c3d14c8STreehugger Robot // ((*(uint64_t *)&s) * (10000 * 2**32)) >> 32 14*7c3d14c8STreehugger Robot // Test that MSan understands that this kills the uninitialized high half of S 15*7c3d14c8STreehugger Robot // (i.e. S::b). FooRun(S s)16*7c3d14c8STreehugger Robotvoid FooRun(S s) { 17*7c3d14c8STreehugger Robot int64_t x = 10000 * s.a; 18*7c3d14c8STreehugger Robot __msan_check_mem_is_initialized(&x, sizeof(x)); 19*7c3d14c8STreehugger Robot } 20*7c3d14c8STreehugger Robot main(void)21*7c3d14c8STreehugger Robotint main(void) { 22*7c3d14c8STreehugger Robot S z(1); 23*7c3d14c8STreehugger Robot // Take &z to ensure that it is built on stack. 24*7c3d14c8STreehugger Robot S *volatile p = &z; 25*7c3d14c8STreehugger Robot FooRun(z); 26*7c3d14c8STreehugger Robot return 0; 27*7c3d14c8STreehugger Robot } 28