1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-14 20:05:05 +00:00
cc65/test/val/bug1397.c

55 lines
805 B
C
Raw Normal View History

2021-02-09 18:50:08 +00:00
/* bug #1937 - Incorrect Behavior Related to OptBoolTrans */
#include <stdio.h>
unsigned char c;
int *p;
void f1(void) {
2021-05-13 16:12:12 +00:00
int i = 1;
int *pa = (int *)0xaaaa;
int *pb = (int *)0xbbbb;
2021-02-09 18:50:08 +00:00
2021-05-13 16:12:12 +00:00
p = (i == 0) ? pa : pb;
c = 0x5a;
2021-02-09 18:50:08 +00:00
}
struct data_t {
2021-05-13 16:12:12 +00:00
unsigned char c;
int *p;
2021-02-09 18:50:08 +00:00
};
struct data_t data;
void f2(void) {
2021-05-13 16:12:12 +00:00
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;
2021-02-09 18:50:08 +00:00
}
int ret = 0;
int main(void) {
2021-05-13 16:12:12 +00:00
f1();
2021-02-09 18:50:08 +00:00
if (c != 0x5a) {
ret++;
}
2021-05-13 16:12:12 +00:00
printf("c: %hhx\n", c);
printf("p: %p\n", p);
f2();
2021-02-09 18:50:08 +00:00
if (data.c != 0xa5) {
ret++;
}
2021-05-13 16:12:12 +00:00
printf("c: %hhx\n", data.c);
printf("p: %p\n", data.p);
2021-02-09 18:50:08 +00:00
2021-05-13 16:12:12 +00:00
printf("failures: %d\n", ret);
2021-02-09 18:50:08 +00:00
return ret;
}