Re: Statically allocated guard pages in ELF

Robert Elz <[email protected]> Sat, 29 Mar 2025 13:09:38 +0700
Newsgroups gmane.os.netbsd.devel.toolchain
Message-ID <[email protected]>
    Date:        Fri, 28 Mar 2025 22:38:50 -0400 (EDT)
    From:        Mouse <[email protected]>
    Message-ID:  <[email protected]>

  | -Wchar-subscripts is my (and possibly your) friend in cases like this.

Only in that exact case, just as (incorrectly) common is

	int c = chararray[N];

	if (iswhatever(c)) ...

Personally, while these kinds of things are very common mistakes,
I think it is something of a fool's errand to attempt to detect
them all at runtime, and while this kind of nonsense

	int c = -123456;

	if (iswhatever(c)) ...

is much less likely, a guard page isn't all that likely to catch that
one (that's unlikely as written, but it can happen if c is fetched from
some (int) location with unpredictable contents).

If the aim were just to make programs that index with negative signed
chars give predictable results, rather than actually diagnosing bad
code, there are much simpler ways to achieve that.

kre