Bug 103942 - [9 Regression] invalid memory reference with allocatable string and class(*)
Summary: [9 Regression] invalid memory reference with allocatable string and class(*)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 10.3.1
: P4 normal
Target Milestone: 10.5
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2022-01-07 15:43 UTC by Antony Lewis
Modified: 2022-06-28 19:46 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build: 2022-01-07 0:00
Known to work:
Known to fail: 9.4.1
Last reconfirmed: 2022-01-07 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Antony Lewis 2022-01-07 15:43:35 UTC
The code works as expected in 9.3.1 20200614. In 10.3.1 20220107 and trunk it gives

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.



    program tester

    character(LEN=:), allocatable :: S

    S = 'CMB'
    call TT(trim(S))

    contains

    subroutine TT(S)
    class(*), intent(in) :: S
    class(*), allocatable :: S2

    allocate(S2, source=S)

    end subroutine TT


    end program tester
Comment 1 Antony Lewis 2022-01-07 16:24:09 UTC
Also broken in 9.4.1 20220107.
Comment 2 Martin Liška 2022-01-07 16:57:25 UTC
Started with r11-6928-g4225af228b5d52e8 and was fixed on master with r12-1005-gfe03f4fc9548b3fd.
Comment 3 anlauf 2022-01-07 17:44:35 UTC
(In reply to Martin Liška from comment #2)
> Started with r11-6928-g4225af228b5d52e8 and was fixed on master with
> r12-1005-gfe03f4fc9548b3fd.

Backporting r12-1005 (see pr100551) fixes the segfault in comment#0 also
for 10-branch.
Comment 4 anlauf 2022-01-07 18:05:32 UTC
Fixed on 10-branch with r10-10384.

Cherrypicking that patch however does not fix the issue on 9-branch.
There must be something else missing which would need backporting.
Comment 5 anlauf 2022-01-17 19:53:12 UTC
After the backport this should have been marked as 9-regression.  Doing so now.
Comment 6 Jakub Jelinek 2022-06-28 10:47:38 UTC
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
Comment 7 anlauf 2022-06-28 19:46:24 UTC
Fixed for gcc-10.4.