From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) by sourceware.org (Postfix) with ESMTPS id F1E873858D20 for ; Mon, 12 Feb 2024 03:14:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F1E873858D20 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 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F1E873858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=128.95.76.21 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707707678; cv=none; b=gWs0w7gf+S9fSi0sGq9yVdbGzOhz2zRCtoO25Sgs5dPMGB8uVitVcvGamUkYnadpkC/Q++ian32cBFKSwl0SFPsKScUEjisa3bkJdcIvk+Lq0GKFRP4Ly0F0fUxhqKacosOjRqRTlx/mMRe7PFAe6NRbxzBLCu+PsORkOEeGQoU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707707678; c=relaxed/simple; bh=D2pAQkUpjlyGz5L7SdEpNuvmoabBoc+IKu+ityxo4Pg=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=Dk0LARU2xVVkgvbWeTCBT78B7b4mpEGsWIdMomOFwcg1wkadJ1SJ4XwQd35MB66Rfk5uxIfxNNqkkCCMQcRNbNMpSbeaif3SrIlJxycr37tOC5ryKQDuA13qNYpB/h5TJGKJWzJEW9UAF0VfpstCsLMh7hB+1p59Y5ZyW8ORBfA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.17.1/8.17.1) with ESMTP id 41C3EYpE054560 for ; Sun, 11 Feb 2024 19:14:34 -0800 (PST) (envelope-from sgk@troutmask.apl.washington.edu) DKIM-Filter: OpenDKIM Filter v2.10.3 troutmask.apl.washington.edu 41C3EYpE054560 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=troutmask.apl.washington.edu; s=troutmask; t=1707707674; bh=D2pAQkUpjlyGz5L7SdEpNuvmoabBoc+IKu+ityxo4Pg=; h=Date:From:To:Subject:Reply-To:References:In-Reply-To:From; b=FzreOy3PMTn35vD3f18rSr3UF8cbu5LABzQSqRQdHwDbZl0R5Ob/4yVu0ys35Gren xvYfHm1m4aROm5UAySvfmFL7UwkMob4cGgifFjTG3IOaJ6xaXWvVdOuweY7Hy9mlTN ggeNWPNb0Xt82eWJwfgLTTaMxIZ670JFOPa4wBEUIF7sYBsLncilEtQWrOX50zXc8A r13QUwiRDC4qfDxx/01O0GiA2VSkcaw5P6MYEDrLnUTWYZGgTjXTs38h26NtTtujdU 4SJrdIGfVGt1DgPEP5PKYonFR5Od14paHwtIeTxiui1ZB9I1wK+CFpCcB8vFcponqM QBDzwKu2FcT3g== Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.17.1/8.17.1/Submit) id 41C3EYDZ054559 for fortran@gcc.gnu.org; Sun, 11 Feb 2024 19:14:34 -0800 (PST) (envelope-from sgk) Date: Sun, 11 Feb 2024 19:14:34 -0800 From: Steve Kargl To: fortran@gcc.gnu.org Subject: Re: Need a hint or more likely help Message-ID: Reply-To: sgk@troutmask.apl.washington.edu References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_INVALID,DKIM_SIGNED,KAM_DMARC_STATUS,KAM_SHORT,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE,WEIRD_PORT 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 Sat, Feb 10, 2024 at 06:00:42PM -0800, Steve Kargl wrote: > All, consider this simple code: > > module foo > contains > subroutine bar > character(len=:), allocatable :: s(:) > call bah(s) > end subroutine bar > end module foo > > If one compiles with -fdump-tree-original, one see (with some pruning) > > void bar () > { > integer(kind=8) .s; > struct array01_character(kind=1) s; > > The above two lines seem to be ok. > > bitsizetype D.4319; > sizetype D.4320; > > try > { > D.4319 = (bitsizetype) (sizetype) NON_LVALUE_EXPR <.s> * 8; > D.4320 = (sizetype) NON_LVALUE_EXPR <.s>; > s.data = 0B; > s.dtype = {.elem_len=(unsigned long) .s, .version=0, .rank=1, .type=6}; > bah ((character(kind=1)[0:][1:.s] * restrict) s.data, .s); > } > > This is bad. .s is undefined. I've trace this to trans-array.cc:11531 I have created PR113883 with the patch suggested by Mikael and a testcase. I have bootstrapped and regression tested the result. Could I ask someone to commit it? https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113883 * trans-array.cc (gfc_trans_deferred_array): Set length of an unallocated character entity to zero to prevent reference to undefined variable. * testsuite/gfortran.dg/allocatable_length.f90: New test. -- Steve