[clang] [compiler-rt] [ubsan] Display correct runtime messages for negative _BitInt (PR #93612)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 10 13:54:30 PDT 2024
================
@@ -0,0 +1,41 @@
+// RUN: %clang -Wno-constant-conversion -Wno-array-bounds -Wno-division-by-zero -Wno-shift-negative-value -Wno-shift-count-negative -Wno-int-to-pointer-cast -O0 -fsanitize=alignment,array-bounds,bool,float-cast-overflow,implicit-integer-sign-change,implicit-signed-integer-truncation,implicit-unsigned-integer-truncation,integer-divide-by-zero,nonnull-attribute,null,nullability-arg,nullability-assign,nullability-return,pointer-overflow,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,unsigned-integer-overflow,unsigned-shift-base,vla-bound %s -o %t1 && %run %t1 2>&1 | FileCheck %s
+
+#include <stdint.h>
+#include <stdio.h>
+
+// In this examples the file is expected to compile&run with no diagnostoctics
+
+// In this test there is an expectation of assignment of _BitInt not producing any output.
+uint32_t nullability_arg(_BitInt(37) *_Nonnull x)
+ __attribute__((no_sanitize("address"))) {
+ _BitInt(37) y = *(_BitInt(37) *)&x;
+ // CHECK-NOT: runtime error:
+ return y;
+}
+
+// In this test there is an expectation of ubsan not triggeting on returning random address which is inside address space of the process.
+_BitInt(37) nonnull_attribute(__attribute__((nonnull)) _BitInt(37) * x)
+ __attribute__((no_sanitize("address"))) {
+ return *(_BitInt(37) *)&x;
+ // CHECK-NOT: runtime error:
----------------
earnol wrote:
Yes. I tested it. One check NOT is enough.
https://github.com/llvm/llvm-project/pull/93612
More information about the cfe-commits
mailing list