boot2

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

134-decl-define-in-ifdef.c (965B)


      1 /* Regression: decl boundary inside an open #ifdef block.
      2  *
      3  * Two top-level forms inside `#ifdef CCSCM ... #endif` — a decl
      4  * followed by a #define — used to corrupt cc.scm's scratch heap. The
      5  * #ifdef pushes onto pps-cond-stack; the typedef ends a top-level decl
      6  * and triggers a scratch reset; promote-iter-buffers! deep-copies the
      7  * surviving pp-state slots into the main heap before the reset, but
      8  * was missing pps-cond-stack from that list. The cond-stack frame
      9  * dangled, and the next #define's %pp-active? walk segfaulted.
     10  *
     11  * The fixture also stands in for the seven `<stdarg.h>`-using
     12  * fixtures (015, 067, 076, 079, 097, 116, 131): all of them gate
     13  * stdarg.h on `#ifndef CCSCM` and define va_list / va_start in the
     14  * else branch — exactly the same dangling-cond-stack shape.
     15  *
     16  * Result: 0. */
     17 
     18 #ifdef CCSCM
     19 typedef char *T;
     20 #define M(x) (x)
     21 #else
     22 typedef char T;
     23 #define M(x) (x)
     24 #endif
     25 
     26 int main(void) { T a; a = 0; return M(0); }