Re: [hackers] A better mailing list web archiver for suckless.org ... ?

From: NRK <nrk_AT_disroot.org>
Date: Thu, 11 Aug 2022 19:20:45 +0600

On Thu, Aug 11, 2022 at 01:41:00PM +0200, Thomas Oltmann wrote:
> This concern is probably completely esoteric, but I can see
> how the pointer could theoretically overflow on some weird system
> where the kernel doesn't sit in the higher half of the address space ...

I'm personally not too worried about overflow. The bigger worry would be
compiler's optimizer producing bad code.

Gcc already does various "optimization" with the assumption that signed
overflow cannot occur [0]. Don't think they *currently* do anything like
that for pointer arithmetic (and probably unlikely they will, as it'd
break too much code).

But this situation is easily avoided by subtracting the "current"
pointer from the "end" pointer and checking weather there's enough space
available or not; which is guaranteed to behave properly by the standard.

Since the goal here can be achieved by a standard method without any
downside, makes sense to use that instead.

[0] interesting thread on the matter: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30475

- NRK
Received on Thu Aug 11 2022 - 15:20:45 CEST

This archive was generated by hypermail 2.3.0 : Thu Aug 11 2022 - 15:24:37 CEST