[compiler-rt] 5953e07 - [NFC][Asan] Fix warning in test (#155447)

via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 26 11:04:01 PDT 2025


Author: Vitaly Buka
Date: 2025-08-26T18:03:59Z
New Revision: 5953e07c8cae6e60bfa7bdafecd7b398cfe9ba4a

URL: https://github.com/llvm/llvm-project/commit/5953e07c8cae6e60bfa7bdafecd7b398cfe9ba4a
DIFF: https://github.com/llvm/llvm-project/commit/5953e07c8cae6e60bfa7bdafecd7b398cfe9ba4a.diff

LOG: [NFC][Asan] Fix warning in test (#155447)

After #150028.

Warning:
```
asan_test.cpp:398:27: error: allocation of insufficient size '0' for type 'int' with size '4'
```

Added: 
    

Modified: 
    compiler-rt/lib/asan/tests/asan_test.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/asan/tests/asan_test.cpp b/compiler-rt/lib/asan/tests/asan_test.cpp
index 85ed3c6769339..d351e15d1e8a2 100644
--- a/compiler-rt/lib/asan/tests/asan_test.cpp
+++ b/compiler-rt/lib/asan/tests/asan_test.cpp
@@ -395,10 +395,8 @@ TEST(AddressSanitizer, ReallocTest) {
   }
   free(ptr);
   // Realloc pointer returned by malloc(0).
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Walloc-size"
-  int *ptr2 = Ident((int*)malloc(0));
-#pragma clang diagnostic pop
+  volatile void *ptr0 = malloc(0);
+  int *ptr2 = Ident((int *)ptr0);
   ptr2 = Ident((int*)realloc(ptr2, sizeof(*ptr2)));
   *ptr2 = 42;
   EXPECT_EQ(42, *ptr2);


        


More information about the llvm-commits mailing list