View previous topic :: View next topic |
Author |
Message |
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Sat Oct 15, 2022 2:08 am Post subject: Syntax error that escapes detection |
|
|
The following program attempts to use an assumed-size array argument as if it were an assumed-shape array. A compiler should be able to catch the error at compile time and refuse to produce an object file or an EXE. FTN95 happily compiles this code!
Code: | program assumed
implicit none
integer, parameter :: N = 100
real :: X(N)
!
call random_number(X)
print *,sadd(X)
contains
real function sadd(X)
implicit none
real X(*) ! note assumed size
sadd = sum(X(:)) ! bug here, X is not assumed shape, size(X) is unknown
return
end function sadd
end program assumed |
In a longer program in which this error existed, the program crashed with an access violation. The /check and /checkmate options did not enable the bug to be detected or located. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Sat Oct 15, 2022 6:57 am Post subject: |
|
|
mecej4
Many thanks for the feedback. I have made a note that this needs fixing. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Sat Oct 15, 2022 8:23 am Post subject: |
|
|
This has now been fixed for the next release of FTN95. |
|
Back to top |
|
|
|