mirror of
https://github.com/cc65/cc65.git
synced 2025-01-09 11:30:29 +00:00
added another testcase for issue #1462
This commit is contained in:
parent
663268dca9
commit
e13f57e86c
51
test/todo/bug1462-2.c
Normal file
51
test/todo/bug1462-2.c
Normal file
@ -0,0 +1,51 @@
|
||||
|
||||
/* issue #1462 - Bit-fields are still broken */
|
||||
/* even the = operation is buggy in certain ways */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
typedef struct {
|
||||
signed int a : 3;
|
||||
signed int b : 3;
|
||||
signed int c : 3;
|
||||
} T;
|
||||
|
||||
int failures = 0;
|
||||
|
||||
T *f(T *t)
|
||||
{
|
||||
t->a = 0;
|
||||
t->c = 0;
|
||||
return t;
|
||||
}
|
||||
|
||||
void test(void)
|
||||
{
|
||||
T a = { 7, 0, 7 };
|
||||
T *p = &a;
|
||||
|
||||
a.b = f(p)->a;
|
||||
|
||||
if (a.a != 0) {
|
||||
++failures;
|
||||
}
|
||||
printf("%d\n", a.a);
|
||||
|
||||
if (p->b != 0) {
|
||||
++failures;
|
||||
}
|
||||
printf("%d\n", p->b);
|
||||
|
||||
if ((&a)->c != 0) {
|
||||
++failures;
|
||||
}
|
||||
printf("%d\n", (&a)->c);
|
||||
|
||||
printf("Failures: %d\n", failures);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
test();
|
||||
return failures;
|
||||
}
|
Loading…
Reference in New Issue
Block a user