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/49110] Deferred-length character result triggers (false positive) error for pure procedures


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

--- Comment #12 from Steve Kargl <sgk at troutmask dot apl.washington.edu> 2011-05-22 21:30:07 UTC ---
On Sun, May 22, 2011 at 08:03:32PM +0000, jwmwalrus at gmail dot com wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49110
> 
> --- Comment #10 from John <jwmwalrus at gmail dot com> 2011-05-22 19:36:33 UTC ---
> (In reply to comment #9)
> > Note the routine need not be pure to invoke the segfault.  Here's
> > an even  shorter test case.
> > 
> > program foo
> >    implicit none
> >    character s(5)
> >    s = ['a', 'b', 'c', 'd', 'e']
> >    print *, bar(s)
> >    contains
> >       function bar(s) result(a)
> > !         character, intent(in) :: s(5)       ! Compiles and runs
> >          character, intent(in) :: s(:)        ! Compiles and segfaults
> >          character(len=:), allocatable :: a
> >          a = repeat('a', size(s))
> >       end function bar
> > end program foo
> 
> My bug report is actually about the fact that the "pure" attribute
> triggers an (incorrect) error, and that error is associated to the
> deferred-length character result.

Sigh.  I already told you that my patch in Comment #2 
fixes the errant error message.  That does not fix the
more important bug that is exposed when the errant
error message is suppressed.  With my patch in Comment #2,
and without touching your source code, I get

laptop:kargl[228] gfc4x -o z -fno-backtrace test_gfortran_pure_main.f90 && ./z
Segmentation fault (core dumped)

> The reason why I used interoperability with C, is because the
> module is just a reduced version of the actual, practical case
>  that triggered the error ---sorry if it's "garbage" to you.

The C interop stuff is garbage in that it makes it much
more difficult to diagnosis and fix the real bug.

Your free to apply my patch gcc, build new gfortran, and use it
to compile and run your code.

I shalt spend anymore time on this PR.


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