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/26038] FORTRAN segfault



------- Comment #8 from eedelman at gcc dot gnu dot org  2006-01-31 11:12 -------
(In reply to comment #7)
> The original code looks like
> 
>    subroutine foo(self)
>     character(*) :: self
>       pointer :: self
>       nullify(self)
>       allocate(self)
>       self = " "
>    end subroutine
> 
> Is this code valid? How can I make it valid?

I think it's valid.  

(The length of 'self', which is needed at allocation, should be passed to foo
by the caller.  For example, the code below should print 
5
10
on execution:

-----------
module moo

contains

    subroutine foo(self)
        character(*) :: self
        pointer :: self

        nullify(self)
        allocate(self)
        print *, len(self)
    end subroutine

end module moo


program hum

    use moo

    character(5), pointer :: p
    character(10), pointer :: q

    call foo(p)
    call foo(q)

end program hum
-----------------
)


-- 

eedelman at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-01-31 11:12:24
               date|                            |


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


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