diff options
author | Alexey Kardashevskiy <aik@ozlabs.ru> | 2017-07-17 13:08:52 +1000 |
---|---|---|
committer | Alexey Kardashevskiy <aik@ozlabs.ru> | 2017-07-19 13:11:15 +1000 |
commit | 4cd2f07ee0f92f652d778d29e9f6ba9254ea90d9 (patch) | |
tree | 8f7fd513268676241837532a04dfdf7c6f25c2df /slof | |
parent | c39657a5f7d502c132a4ae7f407f8281a2ce68e4 (diff) | |
download | SLOF-4cd2f07ee0f92f652d778d29e9f6ba9254ea90d9.zip SLOF-4cd2f07ee0f92f652d778d29e9f6ba9254ea90d9.tar.gz SLOF-4cd2f07ee0f92f652d778d29e9f6ba9254ea90d9.tar.bz2 |
paflof: Silence gcc's -Warray-bounds warning for stack pointers
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@kernel.crashing.org>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
uintptr_t is not used anywhere in SLOF, hence type_u.
Diffstat (limited to 'slof')
-rw-r--r-- | slof/paflof.c | 4 |
1 files 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; |