[libc-commits] [PATCH] D155902: [wip][libc] Overload integer_to_string methods for fixed size buffers

Jon Chesterfield via Phabricator via libc-commits libc-commits at lists.llvm.org
Thu Jul 20 17:18:40 PDT 2023


JonChesterfield added inline comments.


================
Comment at: libc/src/__support/integer_to_string.h:174
+                                          bool lowercase = true) {
     // We will assume the buffer is exactly sized, which will be the case if
     // it was sized using the bufsize method.
----------------
this change ^ really should be a no-op, but seems to be changing the result on amdgpu. That might be a compiler bug.


================
Comment at: libc/test/UnitTest/LibcTest.cpp:53
+  return "0x" + cpp::string(view.data(), view.size());
 }
 
----------------
this ^ looks like the same bug from D155899, but might actually be fine. Placing `__attribute__((warn_unused_result))` on the conversions shows a couple of places. It's possible the wider-than-8 hex case is intended to return values via the passed buffer, not the returned string view. I need to take a closer look.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155902/new/

https://reviews.llvm.org/D155902



More information about the libc-commits mailing list