This seemed kind of weird to me. Am I just up too late?
D:\gfortran\james>type bug5.f90
recursive function bug5(x)
implicit none
character(*), intent(in) :: x
character(:), allocatable :: bug5
bug5 = x
if(bug5(1:1) == 'Z') bug5 = '_'//bug5
end function bug5
6 | if(bug5(1:1) == 'Z') bug5 = '_'//bug5
| 1
Error: 'bug5' at (1) is the name of a recursive function and so refers to
the re
sult variable. Use an explicit RESULT variable for direct recursion (12.5.2.1)
This seemed kind of weird to me. Am I just up too late?
..
D:\gfortran\james>gfortran -c bug5.f90
bug5.f90:6:11:
6 | if(bug5(1:1) == 'Z') bug5 = '_'//bug5
| 1
Error: 'bug5' at (1) is the name of a recursive function and so refers to
the re
sult variable. Use an explicit RESULT variable for direct recursion (12.5.2.1)
You've stayed up far too long without updating - the compiler you're
using is 7.5 years old. Intel Fortran is now free, so no excuse not to update.
This seemed kind of weird to me. Am I just up too late?
On 11/10/2022 10:52 AM, Steve Lionel wrote:
You've stayed up far too long without updating - the compiler you'rePerhaps I woke up too soon - ifort still thinks the code is fine, it was gfortran you were asking about. But my point about updating still holds.
using is 7.5 years old. Intel Fortran is now free, so no excuse not to update.
--
recursive function bug5(x)
implicit none
character(*), intent(in) :: x
character(:), allocatable :: bug5
bug5 = x
if(bug5(1:1) == 'Z') bug5 = '_'//bug5
end function bug5
You've stayed up far too long without updating - the compiler you're
using is 7.5 years old. Intel Fortran is now free, so no excuse not to update.
On Thursday, November 10, 2022 at 2:08:17 AM UTC-8, James Van Buskirk wrote:
recursive function bug5(x)
implicit none
character(*), intent(in) :: x
character(:), allocatable :: bug5
bug5 = x
if(bug5(1:1) == 'Z') bug5 = '_'//bug5
end function bug5
This code is fine. If a compiler complains about it, please submit a bug report if the bug is in the most recent version of the compiler.
recursive function bug5(x)
implicit none
character(*), intent(in) :: x
character(:), allocatable :: bug5
bug5 = x
if(bug5(1:1) == 'Z') bug5 = '_'//bug5
end function bug5
Perhaps I have been up too long myself. I thought the RESULT() syntax was added specifically to allow unambigious recursion and would be the answer
as if bug5() took no parameters what would "//bug5" mean, as () is often optional,
Steve,see that.
Re: "Perhaps I woke up too soon - ifort still thinks the code is fine ..", by phrasing it this way, are you thinking the code is*not* fine? If so, what do you think is the case?
You may recall the previous discussion on a related topic at this forum a few months ago and the Malcolm Cohen feedback you fetched and posted - see the link upthread. Keeping that in mind, you think something is amiss with the code here? I fail to
Perhaps you will also try out NAG compiler?
This does remind me, which version of the standard added allocate
on assignment for the length of CHARACTER variables?
Deferred-length character allocatables were added in F2003.
recursive function bug5(x)
implicit none
character(*), intent(in) :: x
character(:), allocatable :: bug5
bug5 = x
if(bug5(1:1) == 'Z') bug5 = '_'//bug5
end function bug5
This does remind me, which version of the standard added allocate
on assignment for the length of CHARACTER variables?
( I actually see no recursion here, by the way (?)
On Thursday, November 10, 2022 at 2:08:17 AM UTC-8, James Van Buskirk wrote:.
recursive function bug5(x)This code is fine. If a compiler complains about it, please submit a bug report if the bug is in the most recent version of the compiler.
implicit none
character(*), intent(in) :: x
character(:), allocatable :: bug5
bug5 = x
if(bug5(1:1) == 'Z') bug5 = '_'//bug5
end function bug5
This seemed kind of weird to me. Am I just up too late?
D:\gfortran\james>type bug5.f90
recursive function bug5(x)
implicit none
character(*), intent(in) :: x
character(:), allocatable :: bug5
bug5 = x
if(bug5(1:1) == 'Z') bug5 = '_'//bug5
end function bug5
D:\gfortran\james>ifort /c bug5.f90
Intel(R) Visual Fortran Intel(R) 64 Compiler XE for applications running on Inte
l(R) 64, Version 15.0.2.179 Build 20150121
Copyright (C) 1985-2015 Intel Corporation. All rights reserved.
D:\gfortran\james>gfortran -c bug5.f90
bug5.f90:6:11:
6 | if(bug5(1:1) == 'Z') bug5 = '_'//bug5
| 1
Error: 'bug5' at (1) is the name of a recursive function and so refers to
the result variable. Use an explicit RESULT variable for direct recursion (12.5.2.1)
On Friday, November 11, 2022 at 5:09:42 AM UTC+11, Peter Klausler US
wrote:
On Thursday, November 10, 2022 at 2:08:17 AM UTC-8, James Van Buskirk wrote:
recursive function bug5(x)This code is fine. If a compiler complains about it, please submit a bug report if the bug is in the most recent version of the compiler.
implicit none
character(*), intent(in) :: x
character(:), allocatable :: bug5
bug5 = x
if(bug5(1:1) == 'Z') bug5 = '_'//bug5
end function bug5
If the word "recursive" had been omitted, it might have been fine;
the name BUG5 in the IF statement (in 2 places) would have been treated as
if it were an ordinary variable.
With the word "recursive" present, any occurrence of the word BUG5 in an expression
constitutes a recursive reference.
On Thursday, November 10, 2022 at 5:20:16 PM UTC-8, Steve Lionel wrote:
(I wrote)
This does remind me, which version of the standard added allocate
on assignment for the length of CHARACTER variables?
Deferred-length character allocatables were added in F2003.
Just to be sure, also allocate on assignment at the same time?
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 159 |
Nodes: | 16 (0 / 16) |
Uptime: | 99:34:55 |
Calls: | 3,209 |
Files: | 10,563 |
Messages: | 3,009,786 |