This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/41599] [OOP] SELECT TYPE with associate-name => exp: Use (sometimes) a restricted pointer


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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2013-06-16
     Ever confirmed|0                           |1

--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Both

type t
  integer :: item
end type
!type(t),allocatable :: a
class(t),allocatable :: bar
allocate(t::bar)
!allocate(t::a%bar)
select type (foo => bar)
    type is (t)
    foo%item = 8
    bar%item = 9
    print *, foo%item, bar%item
end select
end

and

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

prints

           9           9

It is what I'ld expect, but I don't know if the codes are valid.
Compiling

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

gives an ICE

Program received signal SIGSEGV, Segmentation fault.
0x00000001000b9cc2 in gfc_type_compatible (ts1=<value optimized out>,
ts2=<value optimized out>) at ../../work/gcc/fortran/symbol.c:4483
4483          &&
ts1->u.derived->components->ts.u.derived->attr.unlimited_polymorphic)
(gdb) bt
#0  0x00000001000b9cc2 in gfc_type_compatible (ts1=<value optimized out>,
ts2=<value optimized out>) at ../../work/gcc/fortran/symbol.c:4483
#1  0x000000010006b413 in gfc_match_allocate () at
../../work/gcc/fortran/match.c:3552
#2  0x000000010007f61a in match_word (subr=<value optimized out>,
old_locus=0x7fff5fbfd330, str=<value optimized out>)
    at ../../work/gcc/fortran/parse.c:65
#3  0x0000000100081ff5 in decode_statement () at
../../work/gcc/fortran/parse.c:383
#4  0x000000010008253a in next_statement () at
../../work/gcc/fortran/parse.c:784
#5  0x000000010008335d in parse_spec (st=<value optimized out>) at
../../work/gcc/fortran/parse.c:2741
#6  0x0000000100085599 in parse_progunit (st=<value optimized out>) at
../../work/gcc/fortran/parse.c:4121
#7  0x00000001000866cc in gfc_parse_file () at
../../work/gcc/fortran/parse.c:4637
#8  0x00000001000c6ea6 in gfc_be_parse_file () at
../../work/gcc/fortran/f95-lang.c:189
#9  0x000000010078dd54 in compile_file () at ../../work/gcc/toplev.c:544
#10 0x000000010078fe49 in toplev_main (argc=2, argv=0x7fff5fbfd718) at
../../work/gcc/toplev.c:1872
#11 0x000000010000a804 in start (pc=<value optimized out>, bases=0x0) at
../../../work/libgcc/config/unwind-dw2-fde-darwin.c:272


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]