Skip to content

Conversation

vitalybuka
Copy link
Collaborator

@vitalybuka vitalybuka commented Aug 26, 2025

After #150028.

Warning:

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

Created using spr 1.3.6
@vitalybuka vitalybuka added the skip-precommit-approval PR for CI feedback, not intended for review label Aug 26, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 26, 2025

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Vitaly Buka (vitalybuka)

Changes

After #150028.


Full diff: https://github.com/llvm/llvm-project/pull/155447.diff

1 Files Affected:

  • (modified) compiler-rt/lib/asan/tests/asan_test.cpp (+2-1)
diff --git a/compiler-rt/lib/asan/tests/asan_test.cpp b/compiler-rt/lib/asan/tests/asan_test.cpp
index 2d054ee859ed4..92512c027e381 100644
--- a/compiler-rt/lib/asan/tests/asan_test.cpp
+++ b/compiler-rt/lib/asan/tests/asan_test.cpp
@@ -395,7 +395,8 @@ TEST(AddressSanitizer, ReallocTest) {
   }
   free(ptr);
   // Realloc pointer returned by malloc(0).
-  int *ptr2 = Ident((int*)malloc(0));
+  volatile void* ptr0 = malloc(0);
+  int *ptr2 = Ident((int*)ptr0);
   ptr2 = Ident((int*)realloc(ptr2, sizeof(*ptr2)));
   *ptr2 = 42;
   EXPECT_EQ(42, *ptr2);

Copy link

github-actions bot commented Aug 26, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Created using spr 1.3.6
Copy link
Contributor

@fmayer fmayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe mention which warning in the commit message

Created using spr 1.3.6
@vitalybuka
Copy link
Collaborator Author

Maybe mention which warning in the commit message

done

Created using spr 1.3.6
@vitalybuka vitalybuka enabled auto-merge (squash) August 26, 2025 17:50
Created using spr 1.3.6
@vitalybuka vitalybuka merged commit 5953e07 into main Aug 26, 2025
9 checks passed
@vitalybuka vitalybuka deleted the users/vitalybuka/spr/nfcasan-fix-warning-in-test branch August 26, 2025 18:04
vitalybuka added a commit that referenced this pull request Aug 26, 2025
After #155447.
It's not needed, but does not compile on PowerPC.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler-rt:asan Address sanitizer compiler-rt:sanitizer compiler-rt skip-precommit-approval PR for CI feedback, not intended for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants