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

Damian Rouson sourcery
Thu Nov 6 16:19:45 EST 2014


Thanks!  That makes sense. I suspected it had to do with stripping certain properties from the selector, but I hadn?t thought about the ugly consequences.

It would be great if there were some language to explain what is meant by ?named variable?.  It took me a bit of time to figure out why the offending example wasn?t acceptable.  

________________________________
Damian Rouson, Ph.D., P.E.
Founder & President, Sourcery, Inc.
510-600-2992 (mobile)
http://www.sourceryinstitute.org
http://rouson.youcanbook.me



On Nov 6, 2014, at 1:03 PM, Bader, Reinhold <Reinhold.Bader at lrz.de> wrote:

> 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
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3




More information about the J3 mailing list