From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.smtpout.orange.fr (smtp-25.smtpout.orange.fr [80.12.242.25]) by sourceware.org (Postfix) with ESMTPS id 19DAA3858D20 for ; Fri, 5 May 2023 11:43:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 19DAA3858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=orange.fr Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=orange.fr Received: from [192.168.1.15] ([86.215.161.51]) by smtp.orange.fr with ESMTPA id utqSphmw0GtqgutqSpZFID; Fri, 05 May 2023 13:43:29 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=orange.fr; s=t20230301; t=1683287009; bh=q+RcxbrgsF4f9wUG+oSACWSJhoWpL0u5djoUn+aWQ9s=; h=Date:From:Subject:To:References:In-Reply-To; b=NweFqUAfKssgN6epVqUjf9e0w5Jo+9JUIrYEDc7e1ZFcVNiuyU0v1akiVlv2blImv OAt/YzGNrBV2j1DJfaMFsnsVxyuee24Z1azb5MIdLn8fiWdb1VGwzlUQ0WzJMf+Oy/ ZIf8PrBh/aetH6sBH+pblA+UyRJorLoysEpzeCzOy5LUUKbjrKhFXVxpDUM+XGI6K4 W9cVlNF0kTgOf1vTufZceRQGrqa676v3f6CX6PFitNucavrlb7YQGMQlLUm6kXJD9N A0/U9bubrvQhpdX4RyyfVX1V7QJbq/+jjQoExnL/MlmiMzYXBzAkEXt6fUM/5XncEq G9QgNDuM1Mhfw== X-ME-Helo: [192.168.1.15] X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Fri, 05 May 2023 13:43:29 +0200 X-ME-IP: 86.215.161.51 Message-ID: <618d5f73-55f9-d9d2-e470-aabb5dd7ab17@orange.fr> Date: Fri, 5 May 2023 13:43:28 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 From: Mikael Morin Subject: Re: [PATCH] Fortran: overloading of intrinsic binary operators [PR109641] To: Harald Anlauf , fortran , gcc-patches References: Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,JMQ_SPF_NEUTRAL,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hello, Le 01/05/2023 à 18:29, Harald Anlauf via Fortran a écrit : > Dear all, > > the attached patch is mostly self-explaining: we mishandled the > overloading of intrinsic binary operators in the case the actual > operands were of intrinsic numeric type and the ranks of the > operands were not conformable, i.e. both were of non-zero and > different ranks. In that case the operators could be converted > to the same type before the correct user-defined operator was > resolved, leading to either rejects-valid or accepts-invalid > or wrong resolution (= wrong code). > > Regtested on x86_64-pc-linux-gnu. OK for mainline? > > The patch is actually very limited in impact, but the bug is > sort of annoying. Would it be OK to backport to 13.2 after > some waiting? > > Thanks, > Harald (...) > diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc > index c3d508fb45d..341909d7de7 100644 > --- a/gcc/fortran/resolve.cc > +++ b/gcc/fortran/resolve.cc > @@ -5644,6 +5666,23 @@ done: > } > > > +/* Given two expressions, check that their rank is conformable, i.e. either > + both have the same rank or at least one is a scalar. */ > + > +bool > +gfc_op_rank_conformable (gfc_expr *op1, gfc_expr *op2) > +{ > +// if (op1->expr_type == EXPR_VARIABLE && op1->ref) Please remove this, and the other one below. > + if (op1->expr_type == EXPR_VARIABLE) > + gfc_expression_rank (op1); > +// if (op2->expr_type == EXPR_VARIABLE && op2->ref) > + if (op2->expr_type == EXPR_VARIABLE) > + gfc_expression_rank (op2); > + > + return (op1->rank == 0 || op2->rank == 0 || op1->rank == op2->rank); > +} > + > + > static void > add_caf_get_intrinsic (gfc_expr *e) > { The rest looks good. OK for master, and backport as well. Thanks Mikael