[libcxx-commits] [PATCH] D147640: [libcxxabi] [test] Use the correct printf formats for printing pointers

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Apr 5 10:03:40 PDT 2023


mstorsjo created this revision.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a project: libc++abi.
Herald added a reviewer: libc++abi.

Don't cast the pointers to long, as that's not large enough for
pointers on 64 bit Windows.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147640

Files:
  libcxxabi/test/test_fallback_malloc.pass.cpp


Index: libcxxabi/test/test_fallback_malloc.pass.cpp
===================================================================
--- libcxxabi/test/test_fallback_malloc.pass.cpp
+++ libcxxabi/test/test_fallback_malloc.pass.cpp
@@ -9,6 +9,7 @@
 #include <cstdio>
 #include <deque>
 #include <cassert>
+#include <inttypes.h>
 
 #include <__threading_support>
 
@@ -192,11 +193,11 @@
     print_free_list ();
 
     char *p = (char *) fallback_malloc ( 1024 );    // too big!
-    std::printf("fallback_malloc ( 1024 ) --> %lu\n", (unsigned long ) p);
+    std::printf("fallback_malloc ( 1024 ) --> %" PRIuPTR"\n", (uintptr_t) p);
     print_free_list ();
 
     p = (char *) fallback_malloc ( 32 );
-    std::printf("fallback_malloc ( 32 ) --> %lu\n", (unsigned long) (p - heap));
+    std::printf("fallback_malloc ( 32 ) --> %" PRIuPTR"\n", (uintptr_t) (p - heap));
     if ( !is_fallback_ptr ( p ))
         std::printf("### p is not a fallback pointer!!\n");
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147640.511145.patch
Type: text/x-patch
Size: 953 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230405/84b832c5/attachment.bin>


More information about the libcxx-commits mailing list