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/69423] New: Invalid optimization


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

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