diff --git a/tccgen.c b/tccgen.c index a4fa0cc0..629e07a8 100644 --- a/tccgen.c +++ b/tccgen.c @@ -1871,9 +1871,15 @@ ST_FUNC void gaddrof(void) /* generate a bounded pointer addition */ static void gen_bounded_ptr_add(void) { + int save = (vtop[-1].r & VT_VALMASK) == VT_LOCAL; + if (save) { + vpushv(&vtop[-1]); + vrott(3); + } vpush_global_sym(&func_old_type, TOK___bound_ptr_add); vrott(3); gfunc_call(2); + vtop -= save; vpushi(0); /* returned pointer is in REG_IRET */ vtop->r = REG_IRET | VT_BOUNDED; diff --git a/tests/tests2/117_gcc_test.c b/tests/tests2/117_gcc_test.c index 8b3b782a..aed62e24 100644 --- a/tests/tests2/117_gcc_test.c +++ b/tests/tests2/117_gcc_test.c @@ -129,6 +129,16 @@ void tst_compare(void) if (tst() > 0) printf ("error\n"); } +#pragma pack(1) +struct S { int d:24; int f:14; } i, j; +#pragma pack() + +void tst_pack (void) +{ + i.f = 5; j.f = 5; + if (j.f != i.f) printf("error\n"); +} + int main (void) { @@ -144,4 +154,5 @@ main (void) tst_adr(&sprintf); tst_builtin(); tst_compare(); + tst_pack(); }