testcase for issue #1348
This commit is contained in:
parent
c59e8277ae
commit
23273584a0
2 changed files with 62 additions and 0 deletions
|
@ -117,6 +117,14 @@ $(WORKDIR)/endless.$1.$2.prg: endless.c | $(WORKDIR)
|
|||
$(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
|
||||
$(NOT) $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) $(NULLERR)
|
||||
|
||||
# this one fails when optimization are enabled
|
||||
$(WORKDIR)/bug1348.$1.$2.prg: bug1348.c | $(WORKDIR)
|
||||
$(if $(QUIET),echo misc/bug1348.$1.$2.prg)
|
||||
$(CC65) -Osr -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)
|
||||
$(NOT) $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) $(NULLERR)
|
||||
|
||||
# these need reference data that can't be generated by a host-compiled program,
|
||||
# in a useful way
|
||||
$(WORKDIR)/limits.$1.$2.prg: limits.c $(ISEQUAL) | $(WORKDIR)
|
||||
|
|
54
test/misc/bug1348.c
Normal file
54
test/misc/bug1348.c
Normal file
|
@ -0,0 +1,54 @@
|
|||
|
||||
/* bug#1348, wrongly optimized integer promotion in comparison */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int notrandtab[] = {
|
||||
0xffff, 0x7fff, 0x3fff, 0x1fff,
|
||||
0x0fff, 0x07ff, 0x03ff, 0x01ff,
|
||||
0x00ff, 0x007f, 0x003f, 0x001f,
|
||||
0x000f, 0x0007, 0x0003, 0x0001
|
||||
};
|
||||
|
||||
unsigned char notrandcount = 0;
|
||||
|
||||
int notrand(void)
|
||||
{
|
||||
return notrandtab[notrandcount & 0x0f];
|
||||
}
|
||||
|
||||
unsigned char n1, n2;
|
||||
unsigned char i, ii, s;
|
||||
unsigned char err = 0;
|
||||
|
||||
unsigned char cmptab[] = {
|
||||
0xff, 0x7f, 0x3f, 0x1f,
|
||||
0x0f, 0x07, 0x03, 0x01,
|
||||
0x80, 0x40, 0x20, 0x10,
|
||||
0x08, 0x04, 0x02, 0x01
|
||||
};
|
||||
|
||||
int main(void)
|
||||
{
|
||||
for (ii = 0; ii < 16; ++ii) {
|
||||
s = cmptab[ii];
|
||||
for (i = 0; i < 16; ++i) {
|
||||
n1 = n2 = 0;
|
||||
if ((notrand() & 0xff) > s) {
|
||||
n1 = 1;
|
||||
}
|
||||
if ((notrand() & 0xffu) > s) {
|
||||
n2 = 1;
|
||||
}
|
||||
printf("%5d>%3d %d(%02x) %d(%02x) %s\n",
|
||||
notrandtab[notrandcount & 0x0f], s,
|
||||
n1, (notrand() & 0xff),
|
||||
n2, (notrand() & 0xffu),
|
||||
n1 == n2 ? "=" : "!="
|
||||
);
|
||||
if (n1 != n2) err = 1;
|
||||
notrandcount++;
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
Loading…
Add table
Reference in a new issue