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/57596] New: select type bug with optional variables?


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

            Bug ID: 57596
           Summary: select type bug with optional variables?
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: valeryweber at hotmail dot com

Dear All

The following code is producing a segfault with 
gcc version 4.9.0 20130612 (experimental) (GCC)
Is that a bug?
v



MODULE base_types
  TYPE :: base_integer_type
     INTEGER :: i
  END TYPE base_integer_type
  TYPE :: base_character_type
     CHARACTER( 10 ) :: c
  END TYPE base_character_type
END MODULE base_types

PROGRAM main
  USE base_types
  IMPLICIT NONE
  INTEGER::i_val
  call get (  i_val=i_val )
  write(*,*) 'i_val',i_val
contains

  SUBROUTINE get (i_val, c_val)
    INTEGER, INTENT( OUT ), OPTIONAL :: i_val
    CHARACTER( : ), INTENT( OUT ), ALLOCATABLE, OPTIONAL :: c_val
    CLASS( * ), POINTER :: p
    TYPE( base_integer_type ),target :: i_base
    i_base%i=-12
    p=>i_base
    SELECT TYPE( p )
    TYPE IS( base_integer_type )
       IF(present(i_val)) i_val = p%i
    TYPE IS( base_character_type )
       if(present(c_val)) c_val = p%c
    CLASS DEFAULT
       stop
    END SELECT
  END SUBROUTINE get
END PROGRAM main

./a.out 

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x4120ED in _gfortrani_backtrace at backtrace.c:258
#1  0x401DD0 in _gfortrani_backtrace_handler at compile_options.c:129
#2  0x3FC8C35C1F
#3  0x401C08 in get.1883 at main.f90:?
#4  0x401B71 in MAIN__ at main.f90:?
Segmentation fault (core dumped)


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