[PATCH] D48959: [compiler-rt][ubsan] Implicit Cast Sanitizer - integer truncation - compiler-rt part

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 17 02:19:44 PDT 2018


lebedev.ri added inline comments.


================
Comment at: test/ubsan/TestCases/ImplicitCast/integer-truncation.c:30
+  uint8_t t_b3 = ~((uint64_t)0);
+// CHECK: {{.*}}integer-truncation.c:[[@LINE-1]]:18: runtime error: implicit cast from type 'uint64_t' (aka 'unsigned long') of value 18446744073709551615 (64-bit, unsigned) to type 'uint8_t' (aka 'unsigned char') changed the value to 255 (8-bit, unsigned)
+  uint16_t t_b4 = ~((uint64_t)0);
----------------
vsk wrote:
> This check fails on my system:
> 
> ```
> /Users/vsk/src/llvm.org-lldbsan/llvm/projects/compiler-rt/test/ubsan/TestCases/ImplicitCast/integer-truncation.c:30:11: error: expected string not found in input
> // CHECK: {{.*}}integer-truncation.c:[[@LINE-1]]:18: runtime error: implicit cast from type 'uint64_t' (aka 'unsigned long') of value 18446744073709551615 (64-bit, unsigned) to type 'uint8_t' (aka 'unsigned char') changed the value to 255 (8-bit, unsigned)
>           ^
> <stdin>:6:1: note: scanning from here
> SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/vsk/src/llvm.org-lldbsan/llvm/projects/compiler-rt/test/ubsan/TestCases/ImplicitCast/integer-truncation.c:26:19 in
> ^
> <stdin>:6:1: note: with expression "@LINE-1" equal to "29"
> SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/vsk/src/llvm.org-lldbsan/llvm/projects/compiler-rt/test/ubsan/TestCases/ImplicitCast/integer-truncation.c:26:19 in
> ^
> <stdin>:7:89: note: possible intended match here
> /Users/vsk/src/llvm.org-lldbsan/llvm/projects/compiler-rt/test/ubsan/TestCases/ImplicitCast/integer-truncation.c:29:18: runtime error: implicit cast from type 'uint64_t' (aka 'unsigned long long') of value 18446744073709551615 (64-bit, unsigned) to type 'uint8_t' (aka 'unsigned char') changed the value to 255 (8-bit, unsigned)
>  ```
> 
> I guess on Darwin uint64_t is 'unsigned long long'? Might be best to loosen the check a bit.
Relaxed the `unsigned long long'` case. Any others?


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D48959





More information about the llvm-commits mailing list