https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114141

--- Comment #7 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Wed, Feb 28, 2024 at 07:27:24PM +0000, mikael at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114141
> 
> --- Comment #6 from Mikael Morin <mikael at gcc dot gnu.org> ---
> (In reply to kargl from comment #5)
> > (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.
> > > > 
> > > Not sure how you convinced yourself it isn't. ;-)
> > 
> > x => log(cmplx(-1,0))
> > 
> > R1104 association  is associate-name => 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.
> Agreed.
> 
> >  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.).
> > 
> This is about x%im, which is a different expression from log(cmplx(-1, 0)).
> x is an associate-name, and thus (I think) an object-name, and a valid
> designator, even if it's associated selector isn't.
> 

Indeed.  Bit more reading of F2023, 11.1.3 agrees with you.

   11.1.3.1

   The ASSOCIATE construct associates named entities with expressions
   or variables during the execution of its block.  These named construct
   entities (19.4) are associating entities (19.5.1.6).  The names are
   associate names.

   11.1.3.3(5) The associating entity itself is a variable, but ...

The "but ..." applies to whether the selector is a definable variable.

So, 'y = x%im' is allowed, but 'x%im = 42' is disallowed because
the selector is not definable.  Interesting twist.  This then 
suggests that Jerry's use of parentheses should be accepted.

Reply via email to