Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 1 | // FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316 |
| 2 | // XFAIL: android |
| 3 | |
| 4 | // RUN: %clangxx -fsanitize=undefined %s -O1 -o %t |
| 5 | |
| 6 | // Regular run. |
| 7 | // RUN: %run %t -4 2> %t.out |
| 8 | // RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t.out |
| 9 | |
| 10 | // Good log_path. |
| 11 | // RUN: rm -f %t.log.* |
| 12 | // RUN: env UBSAN_OPTIONS=log_path=%t.log %run %t -4 2> %t.out |
| 13 | // RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t.log.* |
| 14 | |
| 15 | // Run w/o errors should not produce any log. |
| 16 | // RUN: rm -f %t.log.* |
| 17 | // RUN: env UBSAN_OPTIONS=log_path=%t.log %run %t 4 |
| 18 | // RUN: not cat %t.log.* |
| 19 | |
| 20 | // FIXME: log_path is not supported on Windows yet. |
| 21 | // XFAIL: win32 |
| 22 | |
| 23 | #include <stdio.h> |
| 24 | #include <stdlib.h> |
| 25 | int main(int argc, char *argv[]) { |
| 26 | double a = atof(argv[1]); |
| 27 | unsigned int ai = (unsigned int) a; |
| 28 | printf("%f %u\n", a, ai); |
| 29 | return 0; |
| 30 | } |
| 31 | |
| 32 | // CHECK-ERROR: runtime error: value -4 is outside the range of representable values of type 'unsigned int' |
| 33 | |