[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
| Title: | Digital Fortran | 
| Notice: | Read notes 1.* for important information | 
| Moderator: | QUARK::LIONEL | 
|  | 
| Created: | Thu Jun 01 1995 | 
| Last Modified: | Fri Jun 06 1997 | 
| Last Successful Update: | Fri Jun 06 1997 | 
| Number of topics: | 1333 | 
| Total number of notes: | 6734 | 
1278.0. "passing automatic arrays?" by CSC32::J_HENSON (Don't get even, get ahead!) Wed Apr 30 1997 16:31
DFAV V7.1, OpenVMS V7.0, Alpha
Are there any limitations or restrictions to passing automatic arrays
as arguments?  That is, it is ok for subroutine 1 to declare an
automatic array, and pass that array as an argument to subroutine 2?
I have attached an example that illustrates my question.
The reason I ask is that a customer, using dfav v6.3, is getting
an accvio when doing this, but only whan he compiles with /optimize.
If he compiles with /noop, it's ok.  Is there any reason why the
optimizer would be touching an automatic array?  Should it be declared
volatile?
FWIW, when I try the code below on fortran v7.1 with full optimization,
it runs cleanly.  I realize that this doesn't mean that the optimizer
might not do something with it in a larger program, but thought I
should at least mention this.
Thanks,
Jerry
=======================================================================
        program auto_array
        implicit none
        call sub1(10)
        end
c
        subroutine sub1(n)
        integer*4  array(n)
        integer*4  i
c
        do I=1,n
           array(i) = i
        end do
c
        call sub2(array,n)
        return
        end
        subroutine sub2(array,n)
        integer*4 array(n)
        type *,n,array
        return
        end
| T.R | Title | User | Personal Name
 | Date | Lines | 
|---|
| 1278.1 |  | QUARK::LIONEL | Free advice is worth every cent | Wed Apr 30 1997 21:44 | 3 | 
|  |     There are no restrictions - an automatic array is just an array.
    
    				Steve
 | 
| 1278.2 | automatic arrays are allocated on the stack | MSBCS::SCHNEIDER | Say it with ASCII | Thu May 01 1997 08:23 | 4 | 
|  |     Could it be that the customer just ran out of stack space?  It doesn't
    seem surprising that optimized code would need a bit more stack.
    
    Chuck
 | 
| 1278.3 | Thanks | CSC32::J_HENSON | Don't get even, get ahead! | Thu May 01 1997 10:21 | 11 | 
|  | >>     <<< Note 1278.1 by QUARK::LIONEL "Free advice is worth every cent" >>>
>>
>>    There are no restrictions - an automatic array is just an array.
    
Thanks.  That's what I needed to know.  I'll pass that on to the customer.
If they still have problems, I'll request a small reproducer and go
from there.  It's been my experience that about half of the optimizer
problems that I see are cases of poor coding and the optimizer is
uncovering a bug instead of causing one.
Jerry
 | 
| 1278.4 |  | QUARK::LIONEL | Free advice is worth every cent | Thu May 01 1997 11:11 | 3 | 
|  | Only half? :-)
			Steve
 |