12d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s 22d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s 32d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s 42d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s 541f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonov 641f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonov#include <string.h> 741f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonovint main(int argc, char **argv) { 841f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonov static char XXX[10]; 941f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonov static char YYY[10]; 1041f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonov static char ZZZ[10]; 1141f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonov memset(XXX, 0, 10); 1241f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonov memset(YYY, 0, 10); 1341f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonov memset(ZZZ, 0, 10); 1441f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonov int res = YYY[argc * 10]; // BOOOM 1541f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonov // CHECK: {{READ of size 1 at 0x.* thread T0}} 16ed936c1d3a8db321b45d2e249159ec48c6450043Alexey Samsonov // CHECK: {{ #0 0x.* in main .*global-overflow.cc:}}[[@LINE-2]] 1741f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonov // CHECK: {{0x.* is located 0 bytes to the right of global variable}} 1841f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonov // CHECK: {{.*YYY.* of size 10}} 1941f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonov res += XXX[argc] + ZZZ[argc]; 2041f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonov return res; 2141f85b9e6a88f801955d99c8a8233b97e64c51ffAlexey Samsonov} 22