summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug-2376.c
blob: 6748e2de6cb3d0c6fc113e65aed0689cb9c1ea15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
   bug-2195.c

   A peephole optimizer bug in calls to __z88dk_fastcall.
*/

#include <string.h>
#include <testfwk.h>

char v[5];

void kputchar(unsigned char c) __z88dk_fastcall
{
  static int i;
  v[i++] = c;
}

void kputs(const char *p) __z88dk_fastcall
{
  while(*p)
    kputchar(*p++); /* The bug resulted in the peephole optimizer optimizing out the parameter to this call */
}

void testBug(void)
{
  const char *s = "test";
  kputs(s);
  ASSERT(!strcmp(s, v));
}