Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / bug-2625.c
blob521a4a012a22ee55bee31028237728726d37eecd
1 /*
2 bug-2625.c
3 */
5 #include <testfwk.h>
7 struct s {
8 int a,b,c;
9 unsigned char array[512-3*sizeof(int)];
12 int check_ptr(unsigned char *p, struct s *sp)
14 if (p > sp->array + 400) /* Converting the array to its address for the add */
15 return 1; /* incorrectly used the size of the array to */
16 else /* determine the size of the resulting pointer. */
17 return 0;
20 #if !defined( __SDCC_pdk14) && !defined( __SDCC_pdk15) && !defined( __SDCC_pic14) // Lack of memory
21 __xdata struct s teststruct;
22 #endif
24 void testBug (void)
26 #if !defined( __SDCC_pdk14) && !defined( __SDCC_pdk15) && !defined( __SDCC_pic14) // Lack of memory
27 struct s * sp = &teststruct;
29 ASSERT (check_ptr(&(sp->array[400]),sp) == 0);
30 ASSERT (check_ptr(&(sp->array[401]),sp) == 1);
31 #endif