[SLOF] [PATCH] libc: The arguments of puts() can be marked as "const"
Thomas Huth
thuth at redhat.com
Thu Jul 13 17:40:10 AEST 2017
On 12.07.2017 21:24, Segher Boessenkool wrote:
> On Wed, Jul 12, 2017 at 02:56:41PM +0200, Thomas Huth 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;
>>>>>>>> ~~~~~~~~~~~~~~~^~~
>
>> Ugh, ok.
>>
>> What about:
>>
>> dp = the_data_stack;
>> rp = handler_stack;
>> barrier();
>> dp--;
>> rp--;
>>
>> ?
>>
>> That should hopefully shut up the compiler, too, and result in the same
>> initial setting of dp and rp.
>
> I don't know what "barrier" is, but it cannot work :-) Decrementing dp
> is not valid C here, either (exactly the same problem as the original).
>
> You could do just
>
> dp = (cell *)((uintptr_t)the_data_stack - CELLSIZE);
>
> etc. -- that is valid C, standard C even, and will work just fine.
> It's ugly, but at least it is correct ;-)
OK, that solution looks fine to me, too! Alexey, what do you think?
Thomas
More information about the SLOF
mailing list