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