Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / bug-3660.c
blob85677fc4e7df6c6e97d8765eeb3cd9daeb0db71c
1 /* bug-3660.c
2 A segfault in operation width narrowing optimization.
3 */
5 // Based on code by "Under4Mhz" licensed under GPL 2.0 or later
7 #include <testfwk.h>
9 #include <stdint.h>
11 typedef struct {
13 int8_t facing;
14 uint8_t frame;
16 } Enemy;
18 void EnemyRender( Enemy *enemy ) {
20 uint8_t direction = enemy->facing < 0 ? 1: 0;
22 uint8_t frame = enemy->frame / 2;
24 uint8_t frameDirection = direction ? 1 : 0;
27 void
28 testBug( void )
30 Enemy e;
31 e.facing = 0;
32 e.frame = 0;
33 EnemyRender( &e );