1*7c3d14c8STreehugger Robot // Verifies that speculative loads from unions do not happen under asan. 2*7c3d14c8STreehugger Robot // RUN: %clangxx_asan -O0 %s -o %t && %run %t 2>&1 3*7c3d14c8STreehugger Robot // RUN: %clangxx_asan -O1 %s -o %t && %run %t 2>&1 4*7c3d14c8STreehugger Robot // RUN: %clangxx_asan -O2 %s -o %t && %run %t 2>&1 5*7c3d14c8STreehugger Robot // RUN: %clangxx_asan -O3 %s -o %t && %run %t 2>&1 6*7c3d14c8STreehugger Robot 7*7c3d14c8STreehugger Robot typedef union { 8*7c3d14c8STreehugger Robot short q; 9*7c3d14c8STreehugger Robot struct { 10*7c3d14c8STreehugger Robot short x; 11*7c3d14c8STreehugger Robot short y; 12*7c3d14c8STreehugger Robot int for_alignment; 13*7c3d14c8STreehugger Robot } w; 14*7c3d14c8STreehugger Robot } U; 15*7c3d14c8STreehugger Robot main()16*7c3d14c8STreehugger Robotint main() { 17*7c3d14c8STreehugger Robot char *buf = new char[2]; 18*7c3d14c8STreehugger Robot buf[0] = buf[1] = 0x0; 19*7c3d14c8STreehugger Robot U *u = (U *)buf; 20*7c3d14c8STreehugger Robot short result = u->q == 0 ? 0 : u->w.y; 21*7c3d14c8STreehugger Robot delete[] buf; 22*7c3d14c8STreehugger Robot return result; 23*7c3d14c8STreehugger Robot } 24*7c3d14c8STreehugger Robot 25