[SLOF] [PATCH] libc: The arguments of puts() can be marked as "const"

Segher Boessenkool segher at kernel.crashing.org
Fri Jun 9 03:13:35 AEST 2017

On Thu, Jun 08, 2017 at 08:54:06AM +0200, Thomas Huth wrote:
> On 08.06.2017 08:12, Alexey Kardashevskiy wrote:
> > /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;
> >         ~~~~~~~~~~~~~~~^~~
> > /home/aik/p/slof/slof/paflof.c:85:22: warning: array subscript is below
> > array bounds [-Warray-bounds]
> >    rp = handler_stack - 1;
> >         ~~~~~~~~~~~~~~^~~
> > 
> > with gcc (GCC) 6.3.1 20161221 (Red Hat 6.3.1-1) from Fedora24/BE.
> > 
> > Can you please take a look on this? Thanks.
> See Segher's suggestions here:
>  https://lists.ozlabs.org/pipermail/slof/2016-August/001221.html
> IMHO we could also just simply sacrifice the first stack entry and only
> use "dp = the_data_stack", without adding the inline asm here (to keep
> paflof.c portable).

Or you simply make the_*_stack declared as a pointer in paflof.c, not as
an array.  Where is it actually defined?  If it is defined in assembler
code all is fine; if it is defined in C code, well, don't lie to the
compiler or it will take its revenge (if using full-program optimisation
it can still see you're accessing the array out-of-bounds for example,
or worse, assume you don't do undefined things and optimise accordingly).
An easy way around is to have the_*_stack just an external symbol, and
have the_real_*_stack for the arrays of cells, and then equate the two
in a linker script.

Or, ignore the warning.  If ever things break (and they won't), it will
do so with lots of fireworks; it won't silently break.


More information about the SLOF mailing list