https://llvm.org/bugs/show_bug.cgi?id=25569

            Bug ID: 25569
           Summary: UBSan in recoverable mode should kill the program if
                    at least one error was reported
           Product: compiler-rt
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: compiler-rt
          Assignee: vonos...@gmail.com
          Reporter: vonos...@gmail.com
                CC: k...@google.com, llvm-bugs@lists.llvm.org,
                    richard-l...@metafoo.co.uk
    Classification: Unclassified

If the program was compiled with -fsanitize=undefined, we may want
to kill the program with non-zero exit code if at least one problem was
detected and reported at runtime.

True, it's possible to use -fno-sanitize-recover=undefined, or
UBSAN_OPTIONS=halt_on_error=1 to make the failures fatal, but the user may want
to use recoverable mode to see (and keep track of) all the issues currently
reported.

See:

$ cat tmp/a.cc
#include <stdio.h>
#include <stdint.h>

int main() {
  double d = 128.35;
  int8_t i = static_cast<int8_t>(d);
  printf("%d\n", i);
  return 0;
}
$ ./bin/clang++ tmp/a.cc -fsanitize=float-cast-overflow && ./a.out && echo $?
tmp/a.cc:6:34: runtime error: value 128.35 is outside the range of
representable values of type 'signed char'
-128
0

FWIW, the behavior suggested here is what TSan does by default.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to