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

* [Bug fortran/57596] select type bug with optional variables?
  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 ` 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
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-06-12 16:22 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |burnus at gcc dot gnu.org
         Resolution|---                         |INVALID

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Close as INVALID - feel free to re-open if you disagree.


Seems to be invalid. Fortran 2008 has in "8.1.3.3 Attributes of associate
names":

"Within an ASSOCIATE or SELECT TYPE construct [...] If the selector has
the OPTIONAL attribute, it shall be present."


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

* [Bug fortran/57596] Wrong code for allocatable deferred-length strings
  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 ` burnus at gcc dot gnu.org
  2013-06-13  9:14 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-06-13  7:23 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
             Status|RESOLVED                    |REOPENED
   Last reconfirmed|                            |2013-06-13
             Blocks|                            |45170
         Resolution|INVALID                     |---
            Summary|select type bug with        |Wrong code for allocatable
                   |optional variables?         |deferred-length strings
     Ever confirmed|0                           |1

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> ---
REOPEN

PROGRAM main
  IMPLICIT NONE
  call get ()
contains
  SUBROUTINE get (c_val)
    CHARACTER( : ), INTENT( OUT ), ALLOCATABLE, OPTIONAL :: c_val
    CHARACTER( 10 ) :: c_val_tmp
    if(present(c_val)) c_val = c_val_tmp
  END SUBROUTINE get
END PROGRAM main


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

* [Bug fortran/57596] Wrong code for allocatable deferred-length strings
  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
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-06-13  9:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Patch: http://gcc.gnu.org/ml/fortran/2013-06/msg00082.html


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

* [Bug fortran/57596] Wrong code for allocatable deferred-length strings
  2013-06-12 13:54 [Bug fortran/57596] New: select type bug with optional variables? valeryweber at hotmail dot com
                   ` (2 preceding siblings ...)
  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
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-06-14  7:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Author: burnus
Date: Fri Jun 14 07:41:42 2013
New Revision: 200084

URL: http://gcc.gnu.org/viewcvs?rev=200084&root=gcc&view=rev
Log:
2013-06-14  Tobias Burnus  <burnus@net-b.de>

        PR fortran/57596
        * trans-decl.c (gfc_trans_deferred_vars): Honor OPTIONAL
        for nullify and deferred-strings' length variable.

2013-06-14  Tobias Burnus  <burnus@net-b.de>

        PR fortran/57596
        * gfortran.dg/deferred_type_param_9.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/deferred_type_param_9.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/57596] Wrong code for allocatable deferred-length strings
  2013-06-12 13:54 [Bug fortran/57596] New: select type bug with optional variables? valeryweber at hotmail dot com
                   ` (3 preceding siblings ...)
  2013-06-14  7:42 ` burnus at gcc dot gnu.org
@ 2013-06-14  7:43 ` burnus at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-06-14  7:43 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Tobias Burnus <burnus at gcc dot gnu.org> ---
FIXED on the trunk (4.9).

Thanks for the report!


^ 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).