summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug-227710.c
blob: 013ddea84fba74ab55ef370b480b3ddeb2cc4557 (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
/* bug-227710.c
 */
#include <testfwk.h>

static unsigned char dataset[] = {
    1, 2, 3, 4
};

unsigned char *p; 

struct { 
    unsigned char index; 
} s; 

unsigned char 
foo(void) 
{ 
    // BUG, there will be a PRE-increment 
    return p[s.index++];
}

void
testPostIncrement(void)
{
    p = dataset;
    ASSERT(foo() == 1);
    ASSERT(foo() == 2);
    ASSERT(foo() == 3);
    ASSERT(foo() == 4);
}