public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/57596] New: select type bug with optional variables?
@ 2013-06-12 13:54 valeryweber at hotmail dot com
  2013-06-12 16:22 ` [Bug fortran/57596] " burnus at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: valeryweber at hotmail dot com @ 2013-06-12 13:54 UTC (permalink / raw)
  To: gcc-bugs

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)


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-06-14  7:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-12 13:54 [Bug fortran/57596] New: select type bug with optional variables? valeryweber at hotmail dot com
2013-06-12 16:22 ` [Bug fortran/57596] " burnus at gcc dot gnu.org
2013-06-13  7:23 ` [Bug fortran/57596] Wrong code for allocatable deferred-length strings burnus at gcc dot gnu.org
2013-06-13  9:14 ` burnus at gcc dot gnu.org
2013-06-14  7:42 ` burnus at gcc dot gnu.org
2013-06-14  7:43 ` burnus at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).