https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69423

            Bug ID: 69423
           Summary: Invalid optimization
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: antony at cosmologist dot info
  Target Milestone: ---

Using latest svn master branch, the follow code produces wrong results when
compiled with -O1 and higher optimizations:


    program tester
    character(LEN=:), allocatable :: S

    S= test(2)

    contains

        function test(alen)
        character(LEN=:), allocatable :: test
        integer alen, i

        do i = alen, 1, -1
                test = 'test'
                exit
        end do

        !This line prints nothing when compiled with -O1 and higher
        print *, test

        end function test


    end program tester

Reply via email to