mirror of
https://github.com/cc65/cc65.git
synced 2025-01-14 16:33:00 +00:00
Added comments that explain the unstable behavior of a test program.
This commit is contained in:
parent
cd5935deb7
commit
5d4900e179
@ -53,7 +53,7 @@ $(WORKDIR)/sitest%prg: sitest.c
|
||||
-$(CL65) $(subst .,,$(*:.o%=-O%)) $(CC65FLAGS) $< -o $@
|
||||
# -$(SIM65) $(SIM65FLAGS) $@
|
||||
$(WORKDIR)/cc65141011%prg: cc65141011.c
|
||||
@echo "FIXME: " $@ "currently will fail."
|
||||
@echo "FIXME: " $@ "currently can fail."
|
||||
$(CL65) $(subst .,,$(*:.o%=-O%)) $(CC65FLAGS) $< -o $@
|
||||
-$(SIM65) $(SIM65FLAGS) $@
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
!!DESCRIPTION!! equality problem
|
||||
!!ORIGIN!! Testsuite
|
||||
@ -6,32 +5,37 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
different result depending on whether constant is on left or right side
|
||||
Different results, depending on whether constant is on left or right side.
|
||||
|
||||
The optimizer sometimes makes code that executes the right-side expression
|
||||
as eight bits; but then, tests it against the left-side zero as 16 bits.
|
||||
The high-byte is garbage; therefore, that test might, or might not, work.
|
||||
It depends on the platform and the amount of optimization.
|
||||
|
||||
http://www.cc65.org/mailarchive/2014-10/11680.html
|
||||
http://www.cc65.org/mailarchive/2014-10/11682.html
|
||||
http://www.cc65.org/mailarchive/2014-10/11683.html
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static unsigned char fails = 4;
|
||||
static unsigned char bad[3], good[3];
|
||||
|
||||
int main(int n, char **args)
|
||||
int main(void)
|
||||
{
|
||||
unsigned char joy_state = 0x7e;
|
||||
unsigned a, b;
|
||||
|
||||
/* NOTE: somehow it only fails in the printf statement, the other stuff
|
||||
/* NOTE: It fails in only the printf() statements, the other stuff
|
||||
below works! */
|
||||
printf("bad: %u\n", 0 == (joy_state & 1) );
|
||||
printf("bad: %u, ", 0 == (joy_state & 1) );
|
||||
printf("good: %u\n", (joy_state & 1) == 0 );
|
||||
|
||||
sprintf(bad, "%u", 0 == (joy_state & 1) );
|
||||
sprintf(good, "%u", (joy_state & 1) == 0 );
|
||||
|
||||
printf("bad: %u\n", bad[0] - '0' );
|
||||
printf("bad: %u, ", bad[0] - '0' );
|
||||
printf("good: %u\n", good[0] - '0' );
|
||||
|
||||
fails -= bad[0] - '0';
|
||||
@ -40,12 +44,15 @@ int main(int n, char **args)
|
||||
if (0 == (joy_state & 1)) fails--;
|
||||
if ((joy_state & 1) == 0) fails--;
|
||||
|
||||
printf("fails: %u\n", fails );
|
||||
printf("failures: %u\n", fails );
|
||||
|
||||
/* The above printf() returns a value with a zero high-byte.
|
||||
** Therefore, the next (broken) statement works (by accident).
|
||||
*/
|
||||
a = 0 == (joy_state & 1);
|
||||
b = (joy_state & 1) == 0;
|
||||
|
||||
printf("a: %u\n", a );
|
||||
printf("a: %u, ", a );
|
||||
printf("b: %u\n", b );
|
||||
|
||||
return fails;
|
||||
|
Loading…
x
Reference in New Issue
Block a user