[Bug fortran/30003] Expressions with side effects in array references

pault at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Mon Dec 4 20:47:00 GMT 2006



------- Comment #2 from pault at gcc dot gnu dot org  2006-12-04 20:47 -------
(In reply to comment #1)
> I thought I would have time to do something about this bug, but I will not; not
> in the next few weeks/months.  I therefore unassign it from me.  My appologies
> to those who expected to be fixed soon.

That's a pity, Erik, but quite understandable.

I started playing with it at lunchtime.  It's quite an amusing little PR!

As running the test below shows, an array reference 'start' or 'stride' is
always handled correctly, whereas the 'end' is always handled incorrectly.

This suggests that the way to fix this is to add an 'end' field to gfc_ss_info
and to treat it exactly like start, even if it is not used in the scalarizer.

Paul

    implicit none
    integer :: a(5), b(3), cnt

    b = [ 1, 2, 3 ]

    cnt = 0
    a(bar(1):3) = b
    print *, "a(start) => ", cnt, " calls"

    cnt = 0
    a(1:bar(3)) = b
    print *, "a(end) => ", cnt, " calls"

    cnt = 0
    a(1:3:bar(1)) = b
    print *, "a(stride) => ", cnt, " calls"

    cnt = 0
    a(1:3) = b(bar(1):3)
    print *, "b(start) => ", cnt, " calls"

    cnt = 0
    a(1:3) = b(1:bar(3))
    print *, "b(end) => ", cnt, " calls"

    cnt = 0
    a(1:3) = b(1:3:bar(1))
    print *, "b(stride) => ", cnt, " calls"

contains
    integer function bar(n)
        integer, intent(in) :: n
        cnt = cnt + 1
        bar = n
    end function bar
end program foo



-- 


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



More information about the Gcc-bugs mailing list