Closed AGPX closed 1 month ago
#include "common.h" /* Bug in reorg.c, deleting the "++" in the last loop in main. Origin: <hp@axis.com>. */ extern void f (void); extern int x (int, char **); extern int r (const char *); extern char *s (char *, char **); extern char *m (char *); char *u; char *h; int check = 0; int o = 0; int x (int argc, char **argv) { int opt = 0; char *g = 0; char *p = 0; if (argc > o && argc > 2 && argv[o]) { g = s (argv[o], &p); if (g) { *g++ = '\0'; h = s (g, &p); if (g == p) h = m (g); } u = s (argv[o], &p); if (argv[o] == p) u = m (argv[o]); } else abort (); while (++o < argc) if (r (argv[o]) == 0) return 1; return 0; } char *m (char *x) { abort (); } char *s (char *v, char **pp) { if (strcmp (v, "a") != 0 || check++ > 1) abort (); *pp = v+1; return NULL; } int r (const char *f) { static char c[2] = "b"; static int cnt = 0; if (*f != *c || f[1] != c[1] || cnt > 3) abort (); c[0]++; cnt++; return 1; } int main () { const char *args[] = {"a", "b", "c", "d", "e"}; if (x (5, (char **)args) != 0 || check != 2 || o != 5) abort (); exit (0); }
with common.h:
common.h
#pragma once #include <stdio.h> #include <string.h> #define register #define double float #define __attribute__(x) #define __complex__ #define NULL (void *)0 static void abort() { printf("** TEST FAILED **!\n"); } static void abort2(const char *msg) { printf("%s\n", msg); printf("** TEST FAILED **!\n"); }
Does not seem to happen anymore
This test still fails with -O2.
-O2
I get several warnings with this, but no crash
Yep, no crash, but test fails. If you try with -O0, the test passes.
Test passed.
with
common.h
: