summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug3537338.c
blob: 69b16c0ab971225f623038c4958a632e4f0d66ed (plain) (blame)
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
/*
   bug3537338.c
*/

#include <testfwk.h>

#if defined (__SDCC)
 #include <sdcc-lib.h> /* just to get _AUTOMEM or _STATMEM */
#else
 #define _STATMEM
#endif

int globals[3] = {1, 2, 3};
int _STATMEM * ptr = &globals[1];

int get_signed(signed char index)
{
	return *(ptr+index);
}

int get_signedi(int index)
{
	return *(ptr+index);
}

int get_unsigned(unsigned char index)
{
	return *(ptr+index);
}

void testBug(void)
{
#ifndef __SDCC_pic16
    ASSERT (get_signed(-1) == globals[0]);
    ASSERT (get_signedi(-1) == globals[0]);
    ASSERT (get_signed(1) == globals[2]);
    ASSERT (get_unsigned(1) == globals[2]);
#endif
}