This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/46339] [4.3/4.4/4.5/4.6 Regression] ICE (segfault) in gfc_trans_pointer_assignment


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

--- Comment #23 from david.sagan at gmail dot com 2010-11-19 21:24:01 UTC ---
(In reply to comment #22)
> > > Is there something invalid here?
> >
> > Yes.  You need to allocate ptr unless you have
> > pault's [re-]allocate on assignment patch.
> 
> Even with Paul's patch it does not work.

It works for me. The following two variants give the correct result (and this
is without any patching):

program main
 use test
 implicit none
 type(a), target :: myA
 integer, dimension(:), pointer :: ptr
 myA%i(1:4)%j = (/ 1, 2, 3, 4 /)
 myA%i(1:4)%c = (/ 'a', 'b', 'c', 'd' /)
 allocate (ptr(4))
 ptr =  myA%i%j
 print *, "       ptr =", ptr
 print *, "   myA%i%j =", myA%i%j
end program main

program main
 use test
 implicit none
 type(a), target :: myA
 integer, dimension(:), pointer :: ptr
 myA%i(1:4)%j = (/ 1, 2, 3, 4 /)
 myA%i(1:4)%c = (/ 'a', 'b', 'c', 'd' /)
 ptr => myA%i%j
 print *, "       ptr =", ptr
 print *, "   myA%i%j =", myA%i%j
end program main


Both give:
        ptr =           1           2           3           4
    myA%i%j =           1           2           3           4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]