brintos

brintos / llvm-project-archived public Read only

0
0
Text · 539 B · 51051eb Raw
25 lines · cpp
1// Verifies that speculative loads from unions do not happen under asan.2// RUN: %clangxx_asan -O0 %s -o %t && %run %t 2>&13// RUN: %clangxx_asan -O1 %s -o %t && %run %t 2>&14// RUN: %clangxx_asan -O2 %s -o %t && %run %t 2>&15// RUN: %clangxx_asan -O3 %s -o %t && %run %t 2>&16 7typedef union {8  short q;9  struct {10    short x;11    short y;12    int for_alignment;13  } w;14} U;15 16int 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