blob: 78e0d09020809085f13002c84d45cff9b690ee4a (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/* bug-3523.c
Variables on the stack were incorrectly allocated overlapping.
*/
#include <testfwk.h>
#pragma disable_warning 85
// Based on code by "Under4Mhz" licensed under GPL 2.0 or later
#include <stdint.h>
#include <stdbool.h>
typedef struct {
int x;
int y;
} maths_point;
void PlayerGridNextGet( maths_point *next ) {
next->x = 1;
next->y = 2;
}
void PlayerGridGet( maths_point *current ) {
current->x = 3;
current->y = 4;
}
int MapGet( int x, int y ) { return 0; }
int StateDoorHiddenOpenSet( int x, int y ) { ASSERT (x == 1); ASSERT (y == 2);} // Bug visible via x == 3 && y == 4 here.
bool ObjectIsHiddenDoor( char ch ) { return true; }
void SoundDoorOpen() {} // Weirdly, this empty function definition is necesssary to trigger the bug.
void Action() {
maths_point next;
PlayerGridNextGet( &next );
char ch = MapGet( next.x, next.y );
maths_point current;
PlayerGridGet( ¤t );
char chCurrent = MapGet( current.x, current.y );
// Hidden door open
StateDoorHiddenOpenSet( next.x, next.y );
}
void
testBug (void) {
Action();
}
|