From patchwork Mon Jul 17 03:11:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 789194 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3x9pTZ2lWLz9s8V for ; Mon, 17 Jul 2017 13:20:50 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3x9pTZ1ZbzzDrCx for ; Mon, 17 Jul 2017 13:20:50 +1000 (AEST) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org X-Greylist: delayed 545 seconds by postgrey-1.36 at bilbo; Mon, 17 Jul 2017 13:20:44 AEST Received: from ozlabs.ru (ozlabs.ru [107.173.13.209]) by lists.ozlabs.org (Postfix) with ESMTP id 3x9pTS2JqpzDrCl for ; Mon, 17 Jul 2017 13:20:43 +1000 (AEST) Received: from vpl2.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id AF4A03A60011; Sun, 16 Jul 2017 23:11:55 -0400 (EDT) From: Alexey Kardashevskiy To: slof@lists.ozlabs.org Date: Mon, 17 Jul 2017 13:11:02 +1000 Message-Id: <20170717031102.44352-1-aik@ozlabs.ru> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Subject: [SLOF] [PATCH slof] paflof: Silence gcc's -Warray-bounds warning for stack pointers X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" 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 Signed-off-by: Alexey Kardashevskiy Reviewed-by: Thomas Huth --- 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;