struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-3766.c
blobdc83bb22b055ed53ce91ddc3cc6f75fd04d3e181
1 /** bug-3766.c: a bug in an optimization resulted in a wrong type on a struct member of
2 another struct when passed as function parameter, resulting in a unbalanced stack
3 assertion being triggered in code generation when the two structs had different size,
4 */
6 #include <testfwk.h>
8 typedef struct {
9 unsigned len;
10 } Buf;
12 typedef struct {
13 Buf name;
14 unsigned* dp; // Ensure that Search is bigger than Buf.
15 } Search;
17 int compareEntryName(Buf qName);
19 void lookupFunc(Search* s) {
20 compareEntryName(s->name); // Bug triggered on this line.
23 void
24 testBug (void)
26 Search s;
27 s.name.len = 0x55aa;
30 int compareEntryName (Buf qName)
32 ASSERT (qName.len == 0x55aa);