[SLOF] [PATCH slof] paflof: Silence gcc's -Warray-bounds warning for stack pointers
Alexey Kardashevskiy
aik at ozlabs.ru
Mon Jul 17 13:11:02 AEST 2017
The SLOF stack pointers - dp/rp - point to the top used element which
means for an empty stack they point to an element below the stack.
This means that for pushing to the stack we can use a store-with-update
instruction (stdu). This generates good code for most primitives,
better than the other stack pointer offsets.
However, with -Warray-bounds enabled, this produces warnings like below:
At the moment SLOF is gcc produces a warning:
/home/aik/p/slof/slof/paflof.c: In function ‘engine’:
/home/aik/p/slof/slof/paflof.c:84:23: warning: array subscript is below array bounds [-Warray-bounds]
dp = the_data_stack - 1;
~~~~~~~~~~~~~~~^~~
This silences gcc by doing c-cast.
Suggested-by: Segher Boessenkool <segher at kernel.crashing.org>
Signed-off-by: Alexey Kardashevskiy <aik at ozlabs.ru>
---
uintptr_t is not used anywhere in SLOF, hence type_u.
---
slof/paflof.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/slof/paflof.c b/slof/paflof.c
index 50b4adf..e70f601 100644
--- a/slof/paflof.c
+++ b/slof/paflof.c
@@ -81,8 +81,8 @@ long engine(int mode, long param_1, long param_2)
LAST_ELEMENT(xt_FORTH_X2d_WORDLIST).a = xt_LASTWORD;
// stack-pointers
- dp = the_data_stack - 1;
- rp = handler_stack - 1;
+ dp = (cell *)((type_u)the_data_stack - CELLSIZE);
+ rp = (cell *)((type_u)handler_stack - CELLSIZE);
// return-address for "evaluate" personality
dummy.a = &&over;
--
2.11.0
More information about the SLOF
mailing list