30 lines · cpp
1// Test the handle_sigfpe option.2// RUN: %clangxx %s -o %t3// RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK1 %s4// RUN: %env_tool_opts=handle_sigfpe=0 not --crash %run %t 2>&1 | FileCheck --check-prefix=CHECK0 %s5// RUN: %env_tool_opts=handle_sigfpe=1 not %run %t 2>&1 | FileCheck --check-prefix=CHECK1 %s6 7// FIXME: seems to fail on ARM8// REQUIRES: x86_64-target-arch9#include <assert.h>10#include <stdio.h>11#include <sanitizer/asan_interface.h>12 13void death() {14 fprintf(stderr, "DEATH CALLBACK\n");15}16 17int main(int argc, char **argv) {18 __sanitizer_set_death_callback(death);19 volatile int one = 1;20 volatile int zero = 0;21 volatile int sink;22 sink = one / zero;23}24 25// CHECK0-NOT: Sanitizer:DEADLYSIGNAL26// CHECK1: ERROR: {{.*}}Sanitizer: FPE27// CHECK1: {{#[0-9]+.* main .*fpe\.cpp}}:[[@LINE-5]]28// CHECK1: DEATH CALLBACK29// CHECK0-NOT: {{.*}}Sanitizer: FPE30