[Patch, Fortran, OOP] PR 49638: [OOP] length parameter is ignored when overriding type bound character functions with constant length.

Mikael Morin mikael.morin@sfr.fr
Sat Aug 6 16:59:00 GMT 2011


On Saturday 06 August 2011 18:06:58 Janus Weil wrote:
> >> It is wrong to assume that expressions are unequal because we cannot
> >> prove they are equal, with all the limitations that we currently
> >> have.  This will introduce rejects-valid bugs.
> > 
> > In the PR at
> > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49638#c8
> > I quote the standard:
> > 
> > 4.5.7.3 (type-bound procedure overriding) has:
> > • Either both shall be subroutines or both shall be functions having the
> > same result characteristics (12.3.3).
> > 
> > 12.3.3 (Characteristics of function results):
> > If a type parameter of a function result or a bound of a function result
> > array is not a constant expression, the
> > exact dependence on the entities in the expression is a characteristic
> > 
> > 
> > So the standards is more restrictive than expression values being the
> > same. It requires _the exact same dependence on the entities_. My
> > reading of this is that 3*(x+1) vs 3*x+3 is right to be rejected, same
> > for (a+b)+c vs a+(b+c). The only worrying case that I see is the one you
> > pointed out: a+b+c vs c+b+a (without brackets).
> 
> Huh, I don't see what is so different between
> 
> 1) 3*(x+1)   vs  3*x+3   and
> 2) a+b+c  vs  c+b+a
> 
> In both cases the expressions look different at first sight, but can
> be transformed into each other mathematically. So I'd say they are
> mathematically equivalent, although the spelled-out representations of
> these expressions differ.
I was looking at the standard, because I was not so sure myself.
Here is what is written (7.1.5.2.4):

Once the interpretation of a numeric intrinsic operation is established, the 
processor may evaluate any mathematically equivalent expression, provided that 
the integrity of parentheses is not violated.

Two expressions of a numeric type are mathematically equivalent if, for all 
possible values of their primaries, theirmathematical values are equal.


So parentheses have to be respected; other than that anything is possible.
This is about the evaluation of expressions though, not about the "dependences 
on entities".


> 
> The question is how you interpret the standard's formulation of "exact
> dependence on the entities in the expression". 
That is the question.

> Naively I would have
> taken this to mean the *mathematical* dependence (which can be
> represented by different actual expressions). But I'm fine with your
> interpretation, too, which will make life even easier for us.
Yes, my interpretation is somewhat biased towards ease of implementation. ;-)


Mikael



More information about the Gcc-patches mailing list