(j3.2006) Constraint C835: SELECT TYPE selector must be a named variable

Bader, Reinhold Reinhold.Bader
Thu Nov 6 16:03:55 EST 2014


Hello Damian, 

I've occasionally been wondering about this as well. The answer I've come up with 
privately is that the association has the property of removing the ALLOCATABLE 
attribute. Enforcing the use of an associate name in the scenario you prescribe
then precludes rather ugly scenarios like

SELECT TYPE(bar%stuff)
TYPE IS (foo)
  deallocate(bar%stuff)
  allocate(type_from_which_foo_is_extended :: bar%stuff)
  bar%stuff%component_which_does_not_exist_anymore = ...
...
END SELECT

Cheers 

Reinhold


> -----Urspr?ngliche Nachricht-----
> Von: j3-bounces at mailman.j3-fortran.org [mailto:j3-bounces at mailman.j3-
> fortran.org] Im Auftrag von Damian Rouson
> Gesendet: Donnerstag, 6. November 2014 21:54
> An: fortran standards email list for J3
> Betreff: (j3.2006) Constraint C835: SELECT TYPE selector must be a named
> variable
> 
> Could someone tell me the motivation for the following constraint on "select
> type" selectors in the Fortran 2008 standard?
> 
> C835 (R847) If selector is not a named variable, associate-name => shall appear.
> 
> I'm guessing this constraint explains the Cray compiler error message below
> (gfortran gives essentially the same error message).   What's the motivation for
> disallowing the second "select type" statement below?
> 
> On a possibly related note, Note 6.1 states that "P%AGE" is a "variable".  How
> does a "variable" differ from a "named variable"?  I can find the phrase "named
> variable" in only a few places in the standard, but I can't find a definition of it.
> 
> Damian
> 
> 
> p01923 at swan:~> cat selecttype.f90
> program main
> implicit none
> type object
> end type
> type foo
>   class(object), allocatable :: stuff
> end type
> type(foo) :: bar
> 
> select type(barstuff=>bar%stuff ) ! This compiles cleanly end select
> 
> select type(bar%stuff ) ! This gives an error end select
> 
> end
> p01923 at swan:~> ftn selecttype.f90
> 
> select type(bar%stuff ) ! This gives an error
>             ^
> ftn-1875 crayftn: ERROR MAIN, File = selecttype.f90, Line = 13, Column = 15 The
> SELECT TYPE selector must be a named variable or an associate-name must
> appear.
> 
> Cray Fortran : Version 8.3.4 (u83056f83186i83169p83291a83009e83011z83291)
> Cray Fortran :               (x8318r83015w83011t8311b83037)
> Cray Fortran : Sun Nov 02, 2014  10:08:52 Cray Fortran : Compile time:  0.0040
> seconds Cray Fortran : 16 source lines Cray Fortran : 1 errors, 0 warnings, 0
> other messages, 0 ansi Cray Fortran : "explain ftn-message number" gives more
> information about each message.
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3



More information about the J3 mailing list