[SLOF] Compiler warnings
Segher Boessenkool
segher at kernel.crashing.org
Sat Aug 6 03:02:51 AEST 2016
Hi Adrian,
On Fri, Aug 05, 2016 at 05:53:14PM +0200, Adrian Reber wrote:
> With gcc 6.1.1 I see two compiler warnings which I am not sure how to
> solve:
>
> [CC] paflof.o
> /tmp/SLOF/slof/paflof.c: In function ‘engine’:
> /tmp/SLOF/slof/paflof.c:83:23: warning: array subscript is below array bounds [-Warray-bounds]
> dp = the_data_stack - 1;
> ~~~~~~~~~~~~~~~^~~
> /tmp/SLOF/slof/paflof.c:84:22: warning: array subscript is below array bounds [-Warray-bounds]
> rp = handler_stack - 1;
> ~~~~~~~~~~~~~~^~~
I am not sure how to solve it either. The pointer points below the stack
on purpose when the stack is empty. This isn't valid C, but will
generate the correct code.
One way around it is to declare the stacks (in C) as one cell (or more)
bigger, and do some linker tricks to make it start earlier. Another
option is to do some asm trickery, e.g.
dp = the_data_stack;
asm("subi %0,%0,%1" : "+r"(dp) : "n"(CELLSIZE));
or similar.
Or you can shut off the warning, if you trust the compiler generates
correct code anyway:
paflof.o: CFLAGS += -Wno-array-bounds
Segher
More information about the SLOF
mailing list