1 // RUN: %clangxx_asan -O %s -o %t && %run %t
2 
3 // FIXME: merge this with the common longjmp test when we can run common
4 // tests on Windows.
5 
6 #include <assert.h>
7 #include <setjmp.h>
8 #include <stdio.h>
9 #include <sanitizer/asan_interface.h>
10 
11 static jmp_buf buf;
12 
main()13 int main() {
14   char x[32];
15   fprintf(stderr, "\nTestLongJmp\n");
16   fprintf(stderr, "Before: %p poisoned: %d\n", &x,
17           __asan_address_is_poisoned(x + 32));
18   assert(__asan_address_is_poisoned(x + 32));
19   if (0 == setjmp(buf))
20     longjmp(buf, 1);
21   fprintf(stderr, "After:  %p poisoned: %d\n",  &x,
22           __asan_address_is_poisoned(x + 32));
23   // FIXME: Invert this assertion once we fix
24   // https://code.google.com/p/address-sanitizer/issues/detail?id=258
25   assert(!__asan_address_is_poisoned(x + 32));
26 }
27