[Bug fortran/32386] Pure function not allowed in specification expression

2007-06-18 Thread kargl at gcc dot gnu dot org


--- Comment #9 from kargl at gcc dot gnu dot org  2007-06-19 03:50 ---
John,

With your acknowledgment of pault's comment, I think this
can be closed.  Thanks for the reports.  These types of
potential corner cases keep us on our toes.


-- 

kargl at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32386



[Bug fortran/32386] Pure function not allowed in specification expression

2007-06-18 Thread John dot Harper at mcs dot vuw dot ac dot nz


--- Comment #8 from John dot Harper at mcs dot vuw dot ac dot nz  
2007-06-19 01:13 ---
Subject: Re:  Pure function not allowed in specification
 expression

On Tue, 18 Jun 2007, pault at gcc dot gnu dot org wrote:

> Date: 18 Jun 2007 22:49:37 -
> From: pault at gcc dot gnu dot org <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: [Bug fortran/32386] Pure function not allowed in specification
> expression
> 
>
>
> --- Comment #7 from pault at gcc dot gnu dot org  2007-06-18 22:49 ---
> John,
>
> 5.1
> .many snips.
> If a specification-expr involves a reference to a specification function
> (7.1.6.2), the expression is considered to be a nonconstant expression. If the
> data object being declared depends on the value of such a nonconstant
> expression and is not a dummy argument, such an object is called an automatic
> data object.
>
> I can see why you should think that this is OK.  However, this section of the
> standard says otherwise.  In fact, there is a practical consideration, which
> probably drives the standard:
>
> This character length cannot be computed at compilation time because the
> specification function is needed.  Automatic objects in procedures have their
> variable properties calculated in the interface, which is not available for 
> the
> main program. Thus, even were this legal code, I would not have the slightest
> idea how to implement it.
>
> My vote is that this is invalid.

I now agree the code was invalid - I had found 7.1.6.2 but overlooked 
5.1 before sending the bug report. You may be amused to know that some 
compilers do implement that type of automatic data object: g95 and Sun 
f95. However Compaq f95 and NAG f95 disallow it. I don't think a bug
report to g95 or Sun is warranted though: the part of 5.1 that the
program violates is not in a Constraint.

-- John Harper, School of Mathematics, Statistics and Computer Science,
Victoria University, PO Box 600, Wellington 6140, New Zealand
e-mail [EMAIL PROTECTED] phone (+64)(4)463 5341 fax (+64)(4)463 5045


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32386



[Bug fortran/32386] Pure function not allowed in specification expression

2007-06-18 Thread pault at gcc dot gnu dot org


--- Comment #7 from pault at gcc dot gnu dot org  2007-06-18 22:49 ---
John,

5.1
.many snips.
If a specification-expr involves a reference to a specification function
(7.1.6.2), the expression is considered to be a nonconstant expression. If the
data object being declared depends on the value of such a nonconstant
expression and is not a dummy argument, such an object is called an automatic
data object.

I can see why you should think that this is OK.  However, this section of the
standard says otherwise.  In fact, there is a practical consideration, which
probably drives the standard:

This character length cannot be computed at compilation time because the
specification function is needed.  Automatic objects in procedures have their
variable properties calculated in the interface, which is not available for the
main program. Thus, even were this legal code, I would not have the slightest
idea how to implement it.

My vote is that this is invalid.

Paul


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32386



[Bug fortran/32386] Pure function not allowed in specification expression

2007-06-17 Thread kargl at gcc dot gnu dot org


--- Comment #6 from kargl at gcc dot gnu dot org  2007-06-18 04:26 ---
In section 7.1.6.2 (which you sight), I find

  A function is a specification function if it is a pure function, is not an
  intrinsic function, is not an internal function, is not a statement function,
  does not have a dummy procedure argument, and is not defined with the
  RECURSIVE keyword.

Isn't s1 a dummy procedure argument in
 PURE FUNCTION halfit(s1) RESULT (s2)
   CHARACTER(*),INTENT(IN):: s1

Yes, I do get the usage of actual and dummy argument confused at times.
I think stringa is your actual argument and s1 the dummy argument.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32386



[Bug fortran/32386] Pure function not allowed in specification expression

2007-06-17 Thread jvdelisle at gcc dot gnu dot org


--- Comment #5 from jvdelisle at gcc dot gnu dot org  2007-06-18 04:12 
---
>From Fortran 95/2003 Explained, Metcalf. Reid, and Cohen

Page 101:

"The other way that automatic objects arise is through varying character
length. The variable word2 in

  Subroutine example(word1)
character(len = *), intent(inout) :: word1
character(len = len(word1))   :: word2

is an example."


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32386



[Bug fortran/32386] Pure function not allowed in specification expression

2007-06-17 Thread John dot Harper at mcs dot vuw dot ac dot nz


--- Comment #4 from John dot Harper at mcs dot vuw dot ac dot nz  
2007-06-18 02:44 ---
Subject: Re:  Pure function not allowed in specification
 expression

On Mon, 18 Jun 2007, kargl at gcc dot gnu dot org wrote:

> Date: 18 Jun 2007 01:46:09 -
> From: kargl at gcc dot gnu dot org <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: [Bug fortran/32386] Pure function not allowed in specification
> expression
> 
>
>
> --- Comment #2 from kargl at gcc dot gnu dot org  2007-06-18 01:46 ---
> According to Lahey, the code is invalid.
>
> Lahey/Fujitsu Fortran 95 Source Check Output
>
> Compiling program unit halvestring at line 1:
> Compiling program unit testspec at line 9:
>  2049-S: "SOURCE.F90", line 13: Automatic object 'stringb' cannot be specified
> in the main program unit.
> Encountered 1 error, 0 warnings, 0 informations in file SOURCE.F90.
> Compiling file SOURCE.F90.
>
>
> -- 
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32386
>
> --- You are receiving this mail because: ---
> You reported the bug, or are watching the reporter.
>
So I think Lahey is wrong. My stringb is not an automatic object; it is
a character string whose length is LEN of a pure module function of a 
constant.

-- John Harper, School of Mathematics, Statistics and Computer Science,
Victoria University, PO Box 600, Wellington 6140, New Zealand
e-mail [EMAIL PROTECTED] phone (+64)(4)463 5341 fax (+64)(4)463 5045


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32386



[Bug fortran/32386] Pure function not allowed in specification expression

2007-06-17 Thread John dot Harper at mcs dot vuw dot ac dot nz


--- Comment #3 from John dot Harper at mcs dot vuw dot ac dot nz  
2007-06-18 02:42 ---
Subject: Re:  Pure function not allowed in specification
 expression

On Mon, 18 Jun 2007, jvdelisle at gcc dot gnu dot org wrote:

> Date: 18 Jun 2007 01:00:47 -
> From: jvdelisle at gcc dot gnu dot org <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: [Bug fortran/32386] Pure function not allowed in specification
> expression
> 
>
>
> --- Comment #1 from jvdelisle at gcc dot gnu dot org  2007-06-18 01:00 
> ---
> Not saying whether this is valid or not.  However Intel ifort says:
>
> fortcom: Error: john.f90, line 13: An automatic object is invalid in a main
> program.   [STRINGB]
> CHARACTER(len(halfit(stringa))) :: stringb
> ---^
> compilation aborted for john.f90 (code 1)
>
>
> -- 
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32386
>
> --- You are receiving this mail because: ---
> You reported the bug, or are watching the reporter.

I think Intel is wrong because my stringb is not an automatic object.
Its length depends on LEN of a pure module function of a constant.

-- John Harper, School of Mathematics, Statistics and Computer Science,
Victoria University, PO Box 600, Wellington 6140, New Zealand
e-mail [EMAIL PROTECTED] phone (+64)(4)463 5341 fax (+64)(4)463 5045


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32386



[Bug fortran/32386] Pure function not allowed in specification expression

2007-06-17 Thread kargl at gcc dot gnu dot org


--- Comment #2 from kargl at gcc dot gnu dot org  2007-06-18 01:46 ---
According to Lahey, the code is invalid.

Lahey/Fujitsu Fortran 95 Source Check Output

Compiling program unit halvestring at line 1:
Compiling program unit testspec at line 9:
  2049-S: "SOURCE.F90", line 13: Automatic object 'stringb' cannot be specified
in the main program unit.
Encountered 1 error, 0 warnings, 0 informations in file SOURCE.F90.
Compiling file SOURCE.F90.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32386



[Bug fortran/32386] Pure function not allowed in specification expression

2007-06-17 Thread jvdelisle at gcc dot gnu dot org


--- Comment #1 from jvdelisle at gcc dot gnu dot org  2007-06-18 01:00 
---
Not saying whether this is valid or not.  However Intel ifort says:

fortcom: Error: john.f90, line 13: An automatic object is invalid in a main
program.   [STRINGB]
CHARACTER(len(halfit(stringa))) :: stringb
---^
compilation aborted for john.f90 (code 1)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32386