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

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=30373

--- Comment #7 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
This is indeed a problem with aliasing and INTENT(OUT).

When passing this to initoriginal_struct, specifying
intent(out) is telling the compiler that this%var1
contains random garbage, in other words, that you could also write

    subroutine initoriginal_struct(this, var1)
        class(original_struct), intent(out) :: this
        real, intent(in) :: var1
        call random_number(this%var1)
        print*, 'head of initoriginal_struct, the input argument var1 = ', var1
        this%var1 = var1
    end subroutine initoriginal_struct

This will then show up the aliasing problem because var1 is aliased
to this%var1.

gfortran currently does not detect this. There is a longstanding
feature request about this, PR 30373.

Resolving as invalid.

Reply via email to