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