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

            Bug ID: 60334
           Summary: Segmentation fault on character pointer assignments
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: antony at cosmologist dot info

This compiles OK

    program tester
    implicit none  

    character(LEN=:), pointer :: Y
    character(LEN=0), target :: Empty_String = ''

    Y => test()
    print *, Y

    contains

    function test() result(P)
    character(LEN=:), pointer :: P
    P=> Empty_String  

    end function

    end program


but compiled with  gfortran -Og when run gives

Program received signal 11 (SIGSEGV): Segmentation fault.

Backtrace for this error:
  + [0xb776c400]
  + /lib/i386-linux-gnu/libc.so.6(+0x13afcb) [0xb7529fcb]
  + in the main program
    from file TestClass.f90
  + /lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0xb74084d3]
*** glibc detected *** ./a.out: free(): invalid pointer: 0x09be0898 ***

Other compiler options don't so reliably crash, but still probably invalid code
(I think). It's not specific to the string having zero length.

Reply via email to