The code: void mul(double *p) { *p *= 2.0; } failed on x86_64 because register was not loaded after bound checking call. Also printed size when pointer indir failes.
Unified · Split
| @@ -588,8 +588,9 @@ void * __bound_ptr_indir ## dsize (void *p, size_t offset) \ · 587 unmodified lines | ||
| 588 | 588 | if (addr <= tree->size) { \ |
| 589 | 589 | if (tree->is_invalid || addr + offset + dsize > tree->size) { \ |
| 590 | 590 | POST_SEM (); \ |
| 591 | − bound_warning("%p is outside of the region (0x%lx..0x%lx)", \ | |
| 592 | − p + offset, (long)tree->start, \ | |
| 591 | + bound_warning("%p (size %d) is outside of the region " \ | |
| 592 | + "(0x%lx..0x%lx)", \ | |
| 593 | + p + offset, dsize, (long)tree->start, \ | |
| 593 | 594 | (long)(tree->start + tree->size - 1)); \ |
| 594 | 595 | if (never_fatal <= 0) \ |
| 595 | 596 | return INVALID_POINTER; /* return an invalid pointer */ \ |
| @@ -1,2 +1,2 @@ | ||
| 1 | −126_bound_global.c:11: at main: BCHECK: ........ is outside of the region (..................) | |
| 1 | +126_bound_global.c:11: at main: BCHECK: ........ (size 4) is outside of the region (..................) | |
| 2 | 2 | 126_bound_global.c:11: at main: RUNTIME ERROR: invalid memory access |
| @@ -21,9 +21,17 @@ double scale(double d) · 20 unmodified lines | ||
| 21 | 21 | return x.d; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | +void mul(double *p) | |
| 25 | +{ | |
| 26 | + *p *= 2.0; | |
| 27 | +} | |
| 28 | + | |
| 24 | 29 | int |
| 25 | 30 | main(void) |
| 26 | 31 | { |
| 32 | + double d = 4.0; | |
| 27 | 33 | printf("%g\n", scale(42)); |
| 34 | + mul(&d); | |
| 35 | + printf("%g\n", d); | |
| 28 | 36 | return 0; |
| 29 | 37 | } |
| @@ -1 +1,2 @@ | ||
| 1 | 1 | 42000 |
| 2 | +8 | |
| @@ -120,6 +120,7 @@ ST_FUNC void gen_struct_copy(int size); · 119 unmodified lines | ||
| 120 | 120 | |
| 121 | 121 | ST_DATA const char * const target_machine_defs = |
| 122 | 122 | "__x86_64__\0" |
| 123 | + "__x86_64\0" | |
| 123 | 124 | "__amd64__\0" |
| 124 | 125 | ; |
| 125 | 126 | |
| @@ -2020,6 +2021,7 @@ void gen_opf(int op) · 1894 unmodified lines | ||
| 2020 | 2021 | gv(RC_FLOAT); |
| 2021 | 2022 | vswap(); |
| 2022 | 2023 | fc = vtop->c.i; /* bcheck may have saved previous vtop[-1] */ |
| 2024 | + r = vtop->r; | |
| 2023 | 2025 | } |
| 2024 | 2026 | |
| 2025 | 2027 | if ((ft & VT_BTYPE) == VT_DOUBLE) { |