Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / bug-524697.c
blob7c6943e5514bb5186409c4a381661a1186034f42
1 /* Bad addition for adding a length and char[]
2 */
3 #include <testfwk.h>
5 #if defined(__SDCC_mcs51)
6 #define SZ_SIZE 89
7 #else
8 #define SZ_SIZE 90
9 #endif
11 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pic14) // Lack of memory
12 typedef struct _Foo
14 char sz[SZ_SIZE];
15 } Foo;
17 typedef struct _Bar
19 unsigned int uLen;
20 } Bar;
22 char *getOffset(Foo *pFoo, Bar *pBar)
24 return pFoo->sz + pBar->uLen;
26 #endif
28 void
29 testOffset(void)
31 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pic14) // Lack of memory
32 Foo foo = {
33 "Foo"
35 Bar bar = {
39 ASSERT(getOffset(&foo, &bar)
40 == (((char *)&foo) + 3));
41 #endif