------- Comment #5 from burnus at gcc dot gnu dot org  2010-08-19 09:40 -------
(In reply to comment #2)
> Intents for pointers is fine, but not Fortran95 (2003/2008?)

Intents for pointers is Fortran 2003; it applies to the pointer association
status and not to the value.


The programs in comment 0 and comment 2 are both invalid.

  type(inde), pointer :: indexx(:)=>null()

means that "indexx" is initialized - which is only possible for variables which
are in static memory ("SAVE"; the assignment implies the SAVE). That's OK for
the line above, but not for dummy arguments to subroutines.

Note: In C  "int a = 5;" and "int a; a = 5;" have the same meaning. In Fortran
not! "integer :: a = 5" means that "a" is in static memory ("SAVE") and will
only be initialized once at program start. Whereas for "integer :: a; a = 5" 
the assignment happens every time the line is subroutine is called.

 * * *

Regarding the accepts invalid bug:

While for the program in comment 0, gfortran prints the error
  Error: Dummy 'x' at (1) cannot have an initializer
it compiles the program in comment 2.

Note: If one removes the INTENT(OUT) or has (as in comment 0) no derived-type
dummy, the error is printed.


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
           Keywords|                            |accepts-invalid
         Resolution|INVALID                     |
            Summary|intent(out) and pointer =>  |gfortran accepts pointer
                   |null()                      |initialization of DT dummy
                   |                            |arguments w/ INTENT(OUT)


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

Reply via email to