diff options
author | Alexander Richardson <arichardson.kde@gmail.com> | 2023-09-07 11:29:28 -0400 |
---|---|---|
committer | Louis Dionne <ldionne.2@gmail.com> | 2023-09-08 09:15:57 -0400 |
commit | bf1bcb68fc4142c792576b53866df60ead8ac501 (patch) | |
tree | d2ac18638015237f5f92de5aa38aec6f38e52ff6 /clang/lib/CodeGen/CodeGenModule.h | |
parent | dd5af895bb7233471256bb8bfb013d49a71973f0 (diff) | |
download | llvm-bf1bcb68fc4142c792576b53866df60ead8ac501.zip llvm-bf1bcb68fc4142c792576b53866df60ead8ac501.tar.gz llvm-bf1bcb68fc4142c792576b53866df60ead8ac501.tar.bz2 |
[libc++] Use intptr_t instead of ptrdiff_t for messages_base::catalog
On GLibc, FreeBSD and macOS systems nl_catd is a pointer type, and
round-tripping this in a variable of ptrdiff_t is not portable.
In fact such a round-trip yields a non-dereferenceable pointer on
CHERI-enabled architectures such as Arm Morello. There pointers (and
therefore intptr_t) are twice the size of ptrdiff_t, which means casting
to ptrdiff_t strips the high (metadata) bits (as well as a hidden pointer
validity bit).
Since catalog is now guaranteed to be the same size or larger than nl_catd,
we can store all return values safely and the shifting workaround from
commit 0c68ed006d4f38c3cdcab6a565aa3e208015895f should not be needed
anymore (this is also not portable to CHERI systems on since shifting a
valid pointer right will create a massively out-of-bounds pointer that
may not be representable).
This can be fixed by using intptr_t which should be the same type as
ptrdiff_t on all currently supported architectures.
See also: https://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2028
Differential Revision: https://reviews.llvm.org/D134420
Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.h')
0 files changed, 0 insertions, 0 deletions