Re: [PATCH] support ptrdiff_t if it has the same storage size as int, but does not alias it

"'Robin Haberkorn' via scintilla-interest" <[email protected]> Thu, 09 Oct 2025 08:56:17 +0000
Newsgroups gmane.comp.lib.scintilla.devel
Message-ID <[email protected]>
On Sun Oct 5, 2025 at 17:35:04 GMT +03, Robin Haberkorn wrote:
> ...
> The code as it is makes non-portable assumptions.
> Unless of course these platforms somehow violate the
> C standard with their ptrdiff_t definitions, which
> we should check as well.
>

I checked the C23 standard - at least the last free draft (ISO/IEC 9899:2024
(en) — N3220 working draft). ptrdiff_t is just some signed integer large
enough to hold the difference of two pointers. So it's basically a black box.
On 32-bit architectures it could be both `int` and `long` (or `long int`, `signed int`,
`signed long int` etc).
It doesn't seem to be a very wide-spread typedef, though.
It could perhaps also be worked around on the affected platforms by passing
`-fno-strict-aliasing` via CXXFLAGS. But that may come with a performance
penalty.

-- 
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/scintilla-interest/DDDNZRRARIH2.1FTIEW6WYMB19%40googlemail.com.
signature.asc (application/pgp-signature, 488 B)
-----BEGIN PGP SIGNATURE-----

iQEzBAABCAAdFiEEB/6AD3js1eGB4raKarMDYY4q6voFAmjneLIACgkQarMDYY4q
6voiLgf/UveIogT4dUcRQDJf6sIFq+bShs3PwJCV2Dym4QxboZlhbjkp81WmYJMV
b3AU5KwUkMIFnQPNTclKG2rja6n1rKFtMvhSWapxCTn/oAc6ck1Bf1X9hfYxjkOa
T05V0SKJ6JNZmHyyWvKeFid60fuRjRxbiftfBPYCfDTZ7WJpMOoTkoAwnGyjzvRX
de8cXyQWPZzD2J3l3auadn9IEcnWzLRSSPOL/JewMPmD804HURIjrbW7qrC/tNwz
3mH+FsEc1Fq2wTwWtK9tbwHdlHlvSUZFkyXgo0CCJuzHNM3MELbR7uc70NT2iFrd
re1NZvTaH1BcBTxqFc6JnqgKcJSlxw==
=lyW6
-----END PGP SIGNATURE-----