[libcxx-commits] [PATCH] D134420: [libc++] Use intptr_t instead of ptrdiff_t for messages_base::catalog

Alexander Richardson via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Sep 26 04:39:27 PDT 2022


arichardson added inline comments.


================
Comment at: libcxx/include/locale:3464
 public:
-    typedef ptrdiff_t catalog;
+    typedef intptr_t catalog;
 
----------------
Mordante wrote:
> Did you check these types are the same on all supported platforms.
> I noticed `intptr_t` is not guaranteed to be available on all platforms. Is that an issue?
> 
I've looked at clang and for almost all targetinfo classes `PtrDiffType` uses the same type as `IntPtrType`. The only exception I can see is MIPS O32 ABI which uses Int for ptrdiff_t but long for intptr_t (those are the same size just different integer types). In case this is a problem, I'm not sure if MIPS O32 ABI is actually supported - if 32-bit is supported I would assume it's only N32 ABI.

FreeBSD stddef.h checks __SIZEOF_PTRDIFF_T__ and __SIZEOF_POINTER__, so if those match inside clang they will use the same types (which is true for all FreeBSD architectures other than CHERI-extended ones, which are not supported upstream)

I think in theory they could be different with other OS/compiler-provided stddef.h, but I'd be surprised if they were since we don't yet support any architectures that don't have a flat address space (which should imply size_t==intptr_t).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134420



More information about the libcxx-commits mailing list