On some platforms like armv7m, the size() method of containers returns
unsigned long, while ptrdiff_t is just int. Hence, std::ssize_t ends up
being long, which is not the same as ptrdiff_t. This is usually not an
issue because std::ptrdiff_t is long, so everything works out, but it
breaks on some more exotic architectures.
Details
Details
- Reviewers
Mordante - Group Reviewers
Restricted Project - Commits
- rG151a7dafd316: [libc++] Fix ssize test that made an assumption about ptrdiff_t being 'long'
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
returns a type that is larger than ptrdiff_t,
where ptrdiff_t is int, but size_t is still unsigned long. As a result, std::ssize returns long
Unless this is a _really_ special platform, isn't long just 32 bits in this setup? I.e. sizeof(ptrdiff_t) == sizeof(ssize_t), (and sizeof(int) == sizeof(long)), but the root cause is that int and long are two distinct different types even if their sizes happen to match?