From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ciao.gmane.io (ciao.gmane.io [116.202.254.214]) by sourceware.org (Postfix) with ESMTPS id 437C33858CD1 for ; Mon, 19 Feb 2024 19:52:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 437C33858CD1 Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=m.gmane-mx.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 437C33858CD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=116.202.254.214 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708372342; cv=none; b=Iwt6c8oCIAY4pDN7c0qQiZfBxJRqZIbLly/aKJW8MYzzNL/9aPXwMHFypfUKDRWQj/f0iyRKgKKrfkeI3poGMcp9lr3txzXNAx1MPPvzm9rAIHLXui0qRCdsqlMyS7aQU1+AKI/htatDACU5Hjg0UKwPcQ6Jvgvw26rpnZxzok4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708372342; c=relaxed/simple; bh=7ccGM0y/cqJfiNTZt5xcnZbM85E1G6ofmCLAZu4ukkg=; h=To:From:Subject:Date:Message-ID:Mime-Version; b=KlEpIjyoK1arc2nJVIFcKemHlA3PcoVfb33Jv/PsVq1iaMOYl9UUVgZhjx126enqc2wbrKJOV07KUkWcdY4b00jsv7/zj168vDc3ZxT12b6YzZpovJNUTEu5PTceANBo6y6BhujmbYgs6raZvQeLIUFiDI8+Kub6ghoa+D0dlLI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1rc9ga-0009Cs-4U for gcc-patches@gcc.gnu.org; Mon, 19 Feb 2024 20:52:20 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: gcc-patches@gcc.gnu.org From: Harald Anlauf Subject: Re: [PATCH] Fortran: fix passing array component to polymorphic argument [PR105658] Date: Mon, 19 Feb 2024 20:52:14 +0100 Message-ID: <612abd9a-389e-4eab-b1fb-30b22cdaf8ba@gmx.de> References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla Thunderbird Content-Language: en-US In-Reply-To: Cc: fortran@gcc.gnu.org X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: Message-ID: <20240219195214.JdmTpKdfR4LwKOro_QYwLxiFT4qspiRWbB1CYEz6WrM@z> Hi Peter, On 2/19/24 16:19, Peter Hill wrote: > Hi Harald, > > Thanks for your help, please see the updated and signed-off patch below. great! This is fine, and I'll commit it tomorrow unless others have further comments. > It also occurred to me that array temporaries aren't _required_ here > (for arrays of derived type components), but in the general case with > a type with differently sized components, the stride wouldn't be a > multiple of the component's type's size. Is it possible in principle > to have an arbitrary stride? It is possible to have an arbitrary (fixed, non-unit) stride, but it is not always taken advantage of. If you take the last version of the testcase and compile with option -fdump-tree-original, you can see that the cases commented with "no temp needed" actually create a suitable descriptor. E.g. call print_poly (uu(2,2::2)) becomes: { struct __class__STAR_1_0t class.28; struct array01_integer(kind=4) parm.29; class.28._vptr = (struct __vtype__STAR * {ref-all}) &__vtab_INTEGER_4_; parm.29.span = 4; parm.29.dtype = {.elem_len=4, .version=0, .rank=1, .type=1}; parm.29.dim[0].lbound = 1; parm.29.dim[0].ubound = 3; parm.29.dim[0].stride = 10; parm.29.data = (void *) &uu[6]; parm.29.offset = -10; class.28._data = parm.29; class.28._len = 0; print_poly (&class.28); } Since we know that 'uu' is a contiguous array, we can calculate the stride (10) for the 1-d section. The case of the section of the character array is quite similar, but the variant with the substring reference would need further work to avoid the temporary. (It would be possible.) But as you say, the general case, which may involve types/classes, does not map to a simple descriptor. Thanks for your patch! Harald