From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 6DF323888C49; Mon, 20 Feb 2023 09:49:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6DF323888C49 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=troutmask.apl.washington.edu Authentication-Results: sourceware.org; spf=none smtp.mailfrom=troutmask.apl.washington.edu Received: from troutmask.apl.washington.edu ([128.95.76.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pU0XT-0000hT-5p; Mon, 20 Feb 2023 02:24:44 -0500 Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.17.1/8.17.1) with ESMTPS id 31K7OXU8097224 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 19 Feb 2023 23:24:33 -0800 (PST) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.17.1/8.17.1/Submit) id 31K7OXGl097223; Sun, 19 Feb 2023 23:24:33 -0800 (PST) (envelope-from sgk) Date: Sun, 19 Feb 2023 23:24:33 -0800 From: Steve Kargl To: Tobias Burnus Cc: gcc-patches , fortran , Paul Richard Thomas Subject: Re: [Patch] Fortran: Avoid SAVE_EXPR for deferred-len char types Message-ID: Reply-To: sgk@troutmask.apl.washington.edu References: <27cd606a-f019-60b2-a9c8-0a570433b5eb@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Received-SPF: none client-ip=128.95.76.21; envelope-from=sgk@troutmask.apl.washington.edu; helo=troutmask.apl.washington.edu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9,SPF_HELO_NONE=0.001,SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS,SPF_NONE,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, Feb 20, 2023 at 07:56:14AM +0100, Tobias Burnus wrote: > On 17.02.23 17:27, Steve Kargl wrote: > > On Fri, Feb 17, 2023 at 12:13:52PM +0100, Tobias Burnus wrote: > > > OK for mainline? > > Short version: no. > > Would you mind to write a reasoning beyond only a single word? > > > > subroutine foo(n) > > > integer :: n > > > integer :: array(n*5) > > > integer :: my_len > > > ... > > > my_len = 5 > > > block > > > character(len=my_len, kind=4) :: str > > > > > > my_len = 99 > > > print *, len(str) ! still shows 5 - not 99 > > > end block > > > end > > Are you sure about the above comment? > > Yes - for three reasons: > * On the what-feels-right side: It does not make any sense to print > any other value than 5 given that 'str' has been declared with len = 5. > * On the GCC side, the SAVE_EXPR ensures that the length is evaluated > early and then "saved" to ensure its original value is available > * The quoted text from the standard implies that this is what > should happen. Your comment in the above code suggest to me that you expected 99. Of course, the print statement should produce 5 and that is what gfortran does. If your patch only effects deferred character types, why are you including a useless code example. --  steve