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] [6 Regression] Invalid optimization with deferred-length character


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

--- Comment #3 from Paul Thomas <pault at gcc dot gnu.org> ---
Dear Anthony,

In reply to your email message, this one is high on my list of PRs to fix. A
workaround, which could be permanent, is:

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

    S= test(2)
    print *, S

    contains

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

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

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

        end function test


    end program tester

At the moment, I cannot see why an explicit function result should be
different. The code displayed with -fdump-tree-original looks to be the same!

I have set things up in previous patches such that the string length is an
indirect reference to that in the caller. Apparently, in the original testcase
the reference is broken. The memory allocated to 'test' is correct but the
string length remains zero. Even weirder is that this is specific to DO
blocks....

That said, if Andre can see a way to fix it, I would be more than happy to let
him do it :-)

Cheers

Paul

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