mirror of
https://github.com/cc65/cc65.git
synced 2025-08-10 04:25:21 +00:00
added testcase for issue #1937
This commit is contained in:
@@ -108,6 +108,14 @@ $(WORKDIR)/bug1265.$1.$2.prg: bug1265.c | $(WORKDIR)
|
|||||||
$(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
|
$(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
|
||||||
$(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) $(NULLERR)
|
$(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) $(NULLERR)
|
||||||
|
|
||||||
|
# this one fails with optimizations, without OptBoolTrans it works
|
||||||
|
$(WORKDIR)/bug1397.$1.$2.prg: bug1397.c | $(WORKDIR)
|
||||||
|
$(if $(QUIET),echo misc/bug1397.$1.$2.prg)
|
||||||
|
$(CC65) -O --disable-opt OptBoolTrans -t sim$2 -$1 -o $$(@:.prg=.s) $$< $(NULLERR)
|
||||||
|
$(CA65) -t sim$2 -o $$(@:.prg=.o) $$(@:.prg=.s) $(NULLERR)
|
||||||
|
$(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
|
||||||
|
$(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) $(NULLERR)
|
||||||
|
|
||||||
# should compile, but then hangs in an endless loop
|
# should compile, but then hangs in an endless loop
|
||||||
$(WORKDIR)/endless.$1.$2.prg: endless.c | $(WORKDIR)
|
$(WORKDIR)/endless.$1.$2.prg: endless.c | $(WORKDIR)
|
||||||
$(if $(QUIET),echo misc/endless.$1.$2.prg)
|
$(if $(QUIET),echo misc/endless.$1.$2.prg)
|
||||||
|
55
test/misc/bug1397.c
Normal file
55
test/misc/bug1397.c
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
|
||||||
|
/* bug #1937 - Incorrect Behavior Related to OptBoolTrans */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
unsigned char c;
|
||||||
|
int *p;
|
||||||
|
|
||||||
|
void f1(void) {
|
||||||
|
int i = 1;
|
||||||
|
int *pa = (int *)0xaaaa;
|
||||||
|
int *pb = (int *)0xbbbb;
|
||||||
|
|
||||||
|
p = (i == 0) ? pa : pb;
|
||||||
|
c = 0x5a;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct data_t {
|
||||||
|
unsigned char c;
|
||||||
|
int *p;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct data_t data;
|
||||||
|
|
||||||
|
void f2(void) {
|
||||||
|
int i = 1;
|
||||||
|
int *pa = (int *)0xcccc;
|
||||||
|
int *pb = (int *)0xdddd;
|
||||||
|
struct data_t *po = &data;
|
||||||
|
|
||||||
|
po->p = (i == 0) ? pa : pb;
|
||||||
|
po->c = 0xa5;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
f1();
|
||||||
|
if (c != 0x5a) {
|
||||||
|
ret++;
|
||||||
|
}
|
||||||
|
printf("c: %hhx\n", c);
|
||||||
|
printf("p: %p\n", p);
|
||||||
|
f2();
|
||||||
|
if (data.c != 0xa5) {
|
||||||
|
ret++;
|
||||||
|
}
|
||||||
|
printf("c: %hhx\n", data.c);
|
||||||
|
printf("p: %p\n", data.p);
|
||||||
|
|
||||||
|
printf("failures: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
Reference in New Issue
Block a user