http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50684

             Bug #: 50684
           Summary: Incorrect error for move_alloc on intent(in) pointer
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: mstegho...@cistib.upf.edu


Created attachment 25452
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25452
Code to reproduce the behaviour

Bug that was originally posted as additional comment to bug 50570, but turned
out to be a different issue:

The code in the attachment is calling the function move_alloc with something
inside an intent(in) pointer as actual argument and gives the following error
message:

bug.f90:22.20:
    CALL MOVE_ALLOC(POINTER_INTENT_IN_VARIABLE%VALUE, LOCAL_VALUE)
                    1
Error: 'from' argument of 'move_alloc' intrinsic at (1) cannot be INTENT(IN)

I'm not sure about what the Fortran standard says, but I don't think that
giving this error is a desired behaviour because:
* According to documentation of other compilers the code should compile:
http://publib.boulder.ibm.com/infocenter/comphelp/v111v131/topic/com.ibm.xlf131.aix.doc/language_ref/intent.html
(section "Rules", subsection about pointer dummy arguments)
* If INTENT(IN) really tries to protect the *members* (not the pointer itself)
of the derived type from being changed (that's the only scenario in which this
behaviour would make sense), then it's not doing its job: Copying the pointer
to a local variable I'm able to change them, as the example
"POINTER_INTENT_IN_BUG_WORKING" in the attached code shows.

Notes about the attachment:
Subroutine POINTER_INTENT_IN_BUG_FAILING contains the failing code.
Subroutien POINTER_INTENT_IN_BUG_WORKING contains an alternative code that does
the same thing, but compiles (to show that the behaviour of gfortran doesn't
make sense as protection, either).

Reply via email to