From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id IE6cHXJoAWCMPAAAWB0awg (envelope-from ) for ; Fri, 15 Jan 2021 05:03:30 -0500 Received: by simark.ca (Postfix, from userid 112) id 558411EF80; Fri, 15 Jan 2021 05:03:30 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 412421E940 for ; Fri, 15 Jan 2021 05:03:29 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 688C43973015; Fri, 15 Jan 2021 10:03:28 +0000 (GMT) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id B63343846078 for ; Fri, 15 Jan 2021 10:03:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B63343846078 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D9314B7D1; Fri, 15 Jan 2021 10:03:24 +0000 (UTC) Date: Fri, 15 Jan 2021 11:03:23 +0100 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH][gdb/testsuite] Fix gdb.fortran/array-slices.exp with -m32 Message-ID: <20210115100322.GA3283@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Hi, When running test-case gdb.fortran/array-slices.exp with target board unix/-m32, we run into: ... (gdb) print /x &array4d^M $69 = 0xffffb620^M (gdb) print /x (&array4d) + sizeof (array4d)^M $70 = 0x95c620^M (gdb) FAIL: gdb.fortran/array-slices.exp: repack=on: test 9: check sizes match ... The expressions calculate the start and end of an array, but the calculation of the end expression has an unexpected result (given that it lies before the start of the array). By printing "sizeof (array4d)" as a separate expression: ... (gdb) print /x sizeof (array4d) $1 = 0xc40 ... it becomes clear we expected to get 0xffffb620 + 0xc40 == 0xffffc260 instead. The problem is that using the '&' returns a pointer type: ... (gdb) p &array4d $5 = (PTR TO -> ( integer(kind=4) (-3:3,7:10,-3:3,-10:-7) )) 0xffffbe00 ... which has the consequence that the addition is done as pointer arithmetic. Fix this by using the result of "print /x &array4d" instead of &array4d in the addition. Tested on x86_64-linux. Any comments? Thanks, - Tom [gdb/testsuite] Fix gdb.fortran/array-slices.exp with -m32 gdb/testsuite/ChangeLog: 2021-01-15 Tom de Vries PR testsuite/26997 * gdb.fortran/array-slices.exp (run_test): Avoid pointer arithmetic when adding sizeof. --- gdb/testsuite/gdb.fortran/array-slices.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp b/gdb/testsuite/gdb.fortran/array-slices.exp index f45a299b268..45753d9baea 100644 --- a/gdb/testsuite/gdb.fortran/array-slices.exp +++ b/gdb/testsuite/gdb.fortran/array-slices.exp @@ -208,7 +208,7 @@ proc run_test { repack } { set start_addr [get_hexadecimal_valueof "&${full_var_name}" \ "start unknown"] set end_addr [get_hexadecimal_valueof \ - "(&${full_var_name}) + sizeof (${full_var_name})" \ + "$start_addr + sizeof (${full_var_name})" \ "end unknown"] # The Fortran compiler can choose to either send a descriptor that