Bug 25628 - Runtime error on write to string of global variable length
Summary: Runtime error on write to string of global variable length
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: libfortran (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2006-01-01 18:48 UTC by eedelman
Modified: 2006-01-01 19:27 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description eedelman 2006-01-01 18:48:49 UTC
$ cat bug.f90 

module foo
    
    implicit none
    integer :: strlength = 20

contains

    subroutine bar()
        character(len=strlength) :: str
        write (str, *) 0
    end subroutine bar

end module foo


program test_foo
    use foo

    implicit none

    strlength = 10
    call bar()
end program test_foo

$ gfortran bug.f90 
$ a.out
At line 10 of file bug.f90
Fortran runtime error: End of record

I see this behaviour with both 4.1 and mainline.  (With 4.0 I get a segmentation fault at runtime instead.)
Comment 1 Andrew Pinski 2006-01-01 19:07:11 UTC
Is this really a bug, changing the subroutine to:
    subroutine bar()
        character(len=10) :: str
        write (str, *) 0
    end subroutine bar

Also cause the problem, if I increase the size by a couple, it works.
Comment 2 eedelman 2006-01-01 19:27:53 UTC
(In reply to comment #1)
> Is this really a bug, changing the subroutine to:
>     subroutine bar()
>         character(len=10) :: str
>         write (str, *) 0
>     end subroutine bar
> 
> Also cause the problem, if I increase the size by a couple, it works.
> 

I think you are right.  Closing as "INVALID".