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

           Summary: ASSOCIATE: Array descriptor passed to explicit-shaped
                    dummy
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: bur...@gcc.gnu.org
                CC: do...@gcc.gnu.org


Reported by Andrew Baldwin at
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/b1ff1e3da48e6b27

The following program prints with gfortran:

            3           4
            3           4
     33275912           0

With ifort 12 - and reportedly with NAG 5.2, it prints:
           3           4
           3           4
           3           4

If one looks at the dump, one sees that in associated the function is called
as:

        print_int (&bar);

That's both the case for the explicit-shape "i(2)" and for an assumed-shape
"i(:)". As "&bar" is the address of the descriptor, it works with assumed-shape
arrays - and fails with assumed-size/explicit-size arrays.


       subroutine print_int (i)
         integer, intent (in) :: i(2)

         print *, i
       end subroutine print_int

       program main
         interface
           subroutine print_int (i)
             integer, intent (in) :: i(2)
           end subroutine print_int
         end interface

         integer, allocatable :: foo(:,:)

         allocate (foo(2,2))
         foo(:,1) = [1, 2]
         foo(:,2) = [3, 4]

         call print_int (foo(:,2))

         associate (bar => foo(:,2))

         print *, bar

         call print_int (bar)

         end associate
       end program

Reply via email to