Currently, an unrestricted pointer is generated. It should be an restricted
pointer if the expression is not a POINTER or TARGET.

One has to be careful, however:

class(t),allocatable :: bar
allocate(t::a%bar)
select type (foo => bar)
  is type(t)
    foo%item = 8
    bar%item = 9
Here, both items alias - I do not know whether this code is valid or not,
however.

Ditto for

type t2
  class(t) :: bar
end type t2
type(t2) :: a
allocate(t::a%bar)
select type (foo => a%bar)
  is type(t)
    foo%item = 8
    a%bar%item = 9

Similarly for:

type t2
  class(t),allocatable :: bar
end type t2
type(t2), pointer :: a
allocate(a)
allocate(t::a%bar)
select type (foo => a%bar)
  is type(t)
    foo%item = 8
    a%bar%item = 9

Thus before fixing this, one needs to read the standard carefully.


-- 
           Summary: [OOP] SELECT TYPE with associate-name => exp: Use
                    (sometimes) a restricted pointer
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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

Reply via email to