summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug-3503.c
blob: 82511448a3b0055e54ae86d724535313cfd3a852 (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
/* bug-3503.c
   A z80 (and pdk with --stack-auto) codegen issue when comparing pointers to the stack.
 */

#include <testfwk.h>

// Based on code by "Under4Mhz" licensed under GPL 2.0 or later
#include <stdint.h>

#pragma disable_warning 283

typedef struct {

    uint16_t object;

} SegmentData;

void RayDraw() {

    SegmentData segments[22];
    SegmentData *segment = segments;
    uint8_t pos = 0;

    do {

        if ( segment >= segments + 1 ) // Assertion in codegen triggered.
            segment--;

    } while( pos++ < 32 );
}

void
testBug(void)
{
	RayDraw();
}