2 Multiple codegen issues related to bit-fields and pointers to pointers to structs containing them.
7 /// Test derived from code by SF user "Under4Mhz" in 2022.
14 typedef struct { unsigned char x
; unsigned char y
; } maths_point_u8
;
15 typedef struct { int x
; int y
; } maths_point
;
19 maths_point_u8 position
;
20 unsigned char direction
: 4;
21 unsigned char type
: 4;
27 const ObjectData
*objects
;
28 unsigned int objectCount
;
29 const char * const *map
;
30 const ObjectData
*start
;
34 const ObjectData level1Start
= { .direction
= 1, .type
= 1, .position
= { 34, 57 } };
36 const LevelData level1Data
= { .objects
= 0, .objectCount
= 37, .map
= 0, .start
= &level1Start
};
38 const LevelData
*levelData
= &level1Data
;
40 void MapStart( maths_point
*position
, unsigned char *direction
) {
42 position
->x
= levelData
->start
->position
.x
+ 1;
43 position
->y
= levelData
->start
->position
.y
;
44 *direction
= levelData
->start
->direction
; // The write to *direction was generated as if it was a write to a bit-field.
47 void testBug( void ) {
49 unsigned char direction
;
51 MapStart( &p
, &direction
);
53 ASSERT (direction
== 1);