Commit 44adf4f
committed
C backend: fix array out of bounds warning when compiled with -O2 or higher optimizations
- see github # 217 - warning: array subscript -1 is outside array bounds
- caused by fbc's optimization of non-zero lower bound arrays
- fbc calculates a kind of virtual pointer of where the array(0,..) element would be and then computes element addresses from that
- this optimization in fbc saves some computations when accessing array elements but the translation to C is technically undefined behaviour
- fixed (for now) by casting the address to the equivalent of intptr_t in C. (FB_DATATYPE_INTEGER).1 parent d15165a commit 44adf4f
2 files changed
+18
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| 136 | + | |
136 | 137 | | |
137 | 138 | | |
138 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2678 | 2678 | | |
2679 | 2679 | | |
2680 | 2680 | | |
2681 | | - | |
2682 | | - | |
| 2681 | + | |
| 2682 | + | |
| 2683 | + | |
| 2684 | + | |
| 2685 | + | |
| 2686 | + | |
| 2687 | + | |
| 2688 | + | |
| 2689 | + | |
| 2690 | + | |
| 2691 | + | |
| 2692 | + | |
| 2693 | + | |
| 2694 | + | |
| 2695 | + | |
| 2696 | + | |
| 2697 | + | |
2683 | 2698 | | |
2684 | 2699 | | |
2685 | 2700 | | |
| |||
0 commit comments