summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug-3660.c
blob: 85677fc4e7df6c6e97d8765eeb3cd9daeb0db71c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* bug-3660.c
   A segfault in operation width narrowing optimization.
*/

// Based on code by "Under4Mhz" licensed under GPL 2.0 or later

#include <testfwk.h>

#include <stdint.h>

typedef struct {

    int8_t facing;
    uint8_t frame;

} Enemy;

void EnemyRender( Enemy *enemy ) {

    uint8_t direction = enemy->facing < 0 ? 1: 0;

    uint8_t frame = enemy->frame / 2;

    uint8_t frameDirection = direction ? 1 : 0;
}

void
testBug( void )
{
	Enemy e;
	e.facing = 0;
	e.frame = 0;
	EnemyRender( &e );
}