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/59502] New: ICE on invalid on pointer assignment to non-pointer CLASS


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

            Bug ID: 59502
           Summary: ICE on invalid on pointer assignment to non-pointer
                    CLASS
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: abensonca at gmail dot com

The following causes an ICE with gfortran 4.9 (r205975):

module cp

  type :: d
  end type d

  type, public :: p
     class(d) :: pd
  end type p

contains

  function pc(pd)
    implicit none
    type(p) :: pc
    class(d), intent(in), target :: pd
    pc%pd => pd
    return
  end function pc

end module cp

$ gfortran -v
Using built-in specs.
COLLECT_GCC=/opt/gcc-trunk/bin/gfortran
COLLECT_LTO_WRAPPER=/opt/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure --prefix=/opt/gcc-trunk
--enable-languages=c,c++,fortran --disable-multilib
Thread model: posix
gcc version 4.9.0 20131213 (experimental) (GCC) 

$ gfortran test.F90 -o test.o -c
f951: internal compiler error: Segmentation fault
0x9f251f crash_signal
        ../../gcc-trunk/gcc/toplev.c:336
0x5ae283 gfc_match_varspec(gfc_expr*, int, bool, bool)
        ../../gcc-trunk/gcc/fortran/primary.c:2044
0x5ae70d match_variable
        ../../gcc-trunk/gcc/fortran/primary.c:3304
0x58fe19 gfc_match(char const*, ...)
        ../../gcc-trunk/gcc/fortran/match.c:1116
0x590fdc gfc_match_assignment()
        ../../gcc-trunk/gcc/fortran/match.c:1293
0x5a5239 match_word
        ../../gcc-trunk/gcc/fortran/parse.c:65
0x5a61d1 match_word
        ../../gcc-trunk/gcc/fortran/parse.c:327
0x5a61d1 decode_statement
        ../../gcc-trunk/gcc/fortran/parse.c:327
0x5a7741 next_free
        ../../gcc-trunk/gcc/fortran/parse.c:784
0x5a7741 next_statement
        ../../gcc-trunk/gcc/fortran/parse.c:977
0x5a8103 parse_spec
        ../../gcc-trunk/gcc/fortran/parse.c:2768
0x5a9f78 parse_progunit
        ../../gcc-trunk/gcc/fortran/parse.c:4148
0x5aa2fc parse_contained
        ../../gcc-trunk/gcc/fortran/parse.c:4087
0x5ab50d parse_module
        ../../gcc-trunk/gcc/fortran/parse.c:4350
0x5ab50d gfc_parse_file()
        ../../gcc-trunk/gcc/fortran/parse.c:4652
0x5e8ff5 gfc_be_parse_file
        ../../gcc-trunk/gcc/fortran/f95-lang.c:188
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.

The code is invalid as "pd" should have either allocatable or pointer
attributes. If the pointer assignment "pc%pd => pd" is removed then compilation
correctly fails with:

$ gfortran test.F90 -o test.o -c
test.F90:7.19:

     class(d) :: pd
                   1
Error: Component 'pd' with CLASS at (1) must be allocatable or pointer


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