This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/46339] [4.3/4.4/4.5/4.6 Regression] ICE (segfault) in gfc_trans_pointer_assignment
- From: "david.sagan at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 19 Nov 2010 21:24:07 +0000
- Subject: [Bug fortran/46339] [4.3/4.4/4.5/4.6 Regression] ICE (segfault) in gfc_trans_pointer_assignment
- Auto-submitted: auto-generated
- References: <bug-46339-4@http.gcc.gnu.org/bugzilla/>
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