boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

commit 34257e04a2beb2249af0ef36ac3cde0f2e3f86cb
parent 3d092914a70e99f5e3707e25f641e221b1695354
Author: Ryan Sepassi <rsepassi@gmail.com>
Date:   Mon, 27 Apr 2026 02:17:08 -0700

cc tests: lock in void* byte-arithmetic semantics

void *p; p + N is byte-arithmetic (GCC ext / tcc-mes assumption);
strict C99 disallows it. cg-binop's ptr-arith branch already does the
right thing because the (> sz 1) guard short-circuits scaling for
char* (size 1) and void* (size -1, pointee), naturally yielding byte
arithmetic for both. Lock-in fixture so the invariant doesn't regress.

tests/cc-parse/78-voidptr-arith.c casts char[] to void*, advances by
2, casts back, and dereferences; expects 'C' = 67.

Diffstat:
Atests/cc-parse/78-voidptr-arith.c | 17+++++++++++++++++
Atests/cc-parse/78-voidptr-arith.expected-exit | 1+
2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/tests/cc-parse/78-voidptr-arith.c b/tests/cc-parse/78-voidptr-arith.c @@ -0,0 +1,17 @@ +/* void* arithmetic via the GCC byte-arithmetic extension. + * + * tcc.c relies on `void *p; p + N` being byte-stride pointer + * arithmetic. Strict C99 disallows it (no arithmetic on void*); we + * follow GCC and tcc-mes. + * + * Buffer: { 'A', 'B', 'C', 'D', 0 }. void* + 2 + cast to char* + deref + * yields 'C' = 67. + */ + +char buf[] = "ABCD"; + +int main(void) { + void *p = buf; + char *q = (char *)(p + 2); + return *q; +} diff --git a/tests/cc-parse/78-voidptr-arith.expected-exit b/tests/cc-parse/78-voidptr-arith.expected-exit @@ -0,0 +1 @@ +67