From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9877F3858D39; Wed, 28 Feb 2024 18:13:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9877F3858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709144030; bh=vuZXgP0wn4zeRtzT7f8RL5CcC3P9BxKdhSf572IAVwI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=wJFfpLjteAz2HVxluJTbHI+NmArgb+CFGwr7gDcGohkmnSE6kz4FeLjrz78z9cy91 Jm3BrW5Ky3SKOO1MCRZ0pBDqVdMqlxWSdqefDxjRWRPbGBlfEfMsyVPez3ZSOXDltD johKoNxyJilFwxKm16F+JMExbyuxZjiRstQoOjMM= From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/114141] ASSOCIATE and complex part ref when associate target is a function Date: Wed, 28 Feb 2024 18:13:49 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: kargl at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P5 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: priority bug_severity Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114141 kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P4 |P5 Severity|normal |enhancement --- Comment #5 from kargl at gcc dot gnu.org --- (In reply to Mikael Morin from comment #4) > (In reply to kargl from comment #3) > > Yep, agreed. I went back an re-read the section about ASSOCIATE. > > Not sure how I convinced myself that a constant expression, which > > reduces to a constant is okay. > >=20 > Not sure how you convinced yourself it isn't. ;-) x =3D> log(cmplx(-1,0)) R1104 association is associate-name =3D> selector R1105 selector is expr or variable R902 variable is designator or function-reference R901 designator is object-name or array-element or array-section or coindexed-named-object or complex-part-designator or structure-component or substring log(cmplx(-1,0)) is certainly not a designator. log(cmplx(-1,0)) is a function-reference. But this then leads to C902 (R902) function-reference shall have a data pointer result. log(cmplx(-1,0)) violates C902, so this then means that it must be an expr. One now needs R915 complex-part-designator is designator % RE or designator % IM C922 (R915) The designator shall be of complex type. which shows that expr%im is invalid; even though log(cmplx(-1,0)) reduces to a constant (i.e., it's not a named constant. This is likely the error [pun intended] in my ways.). Sometimes the trees get in the way of seeing the forest. Arguably, the error message is wrong gfortran13 -c a.f90 a.f90:6:13: 6 | y =3D x%im | 1 Error: Symbol 'x' at (1) has no IMPLICIT type 'x' has the type of COMPLEX. The version of the code where Jerry wraps log(cmplx(-1,0)) in parentheses. Generates a better error message $ gfc pr114141.f90 pr114141.f90:6:14: 6 | y =3D x%im | 1 Error: The RE or IM part_ref at (1) must be applied to a COMPLEX expression but this is still wrong in that RE and IM are applied to a designator. I'll leave the PR open has an enhancement request.=