int test() { struct { int i; } s = { 42 }; return s.i; // bound checked }
Unified · Split
| @@ -6234,7 +6234,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 6233 unmodified lines | |||
| 6234 | if ((r & VT_VALMASK) == VT_LOCAL) { | 6234 | if ((r & VT_VALMASK) == VT_LOCAL) { |
| 6235 | sec = NULL; | 6235 | sec = NULL; |
| 6236 | #ifdef CONFIG_TCC_BCHECK | 6236 | #ifdef CONFIG_TCC_BCHECK |
| 6237 | if (tcc_state->do_bounds_check && (type->t & VT_ARRAY)) { | 6237 | if (tcc_state->do_bounds_check && ((type->t & VT_ARRAY) || (type->t & VT_BTYPE) == VT_STRUCT)) { |
| 6238 | loc--; | 6238 | loc--; |
| 6239 | } | 6239 | } |
| 6240 | #endif | 6240 | #endif |
| @@ -6244,7 +6244,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 3 unmodified lines | |||
| 6244 | /* handles bounds */ | 6244 | /* handles bounds */ |
| 6245 | /* XXX: currently, since we do only one pass, we cannot track | 6245 | /* XXX: currently, since we do only one pass, we cannot track |
| 6246 | '&' operators, so we add only arrays */ | 6246 | '&' operators, so we add only arrays */ |
| 6247 | if (tcc_state->do_bounds_check && (type->t & VT_ARRAY)) { | 6247 | if (tcc_state->do_bounds_check && ((type->t & VT_ARRAY) || (type->t & VT_BTYPE) == VT_STRUCT)) { |
| 6248 | addr_t *bounds_ptr; | 6248 | addr_t *bounds_ptr; |
| 6249 | /* add padding between regions */ | 6249 | /* add padding between regions */ |
| 6250 | loc--; | 6250 | loc--; |