public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/46588] New: Segfault on automatic function
@ 2010-11-21 12:59 oleg.steblev at gmail dot com
  2010-11-21 19:19 ` [Bug fortran/46588] " oleg.steblev at gmail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: oleg.steblev at gmail dot com @ 2010-11-21 12:59 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Segfault on automatic function
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: oleg.steblev@gmail.com


$ cat check.f90
program ds
implicit none
character(len = 4) :: ins = '+ - '
character(len = 20) st, aufun 
st = aufun(ins) ! результата равна n
print *, st
end

function aufun(pm)
character(len = *) pm
character(len = *) aufun
character(len = len(aufun)) temp 
temp = pm // pm //pm // pm 
aufun = '# ' // trim(temp) // ' #'
end

$ gfortran -v check.f90
Target: i686-pc-cygwin
compiled by GNU C version 4.3.2 20080827 (beta) 2, GMP version 4.2.4, MPFR
version 2.4.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
check.f90:7: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

$cat check2.f90
function aufun(pm)
character(len = *) pm
character(len = *) aufun
SAVE character(len = len(aufun)) temp 
temp = pm // pm //pm // pm 
aufun = '# ' // trim(temp) // ' #'
end

$ gfortran check2.f90
check2.f90:4.15:

 SAVE character(len = len(afun)) temp ! \xD1\xF2\xF0\xEE\xEA\xE0 temp -
\xEF\xF0\xE8\xEC\xE5\xF0
              1
Error: Syntax error in SAVE statement at (1)
check2.f90:5.8:

 temp = pm // pm //pm // pm !
\xE0\xE2\xF2\xEE\xEC\xE0\xF2\xE8\xF7\xE5\xF1\xEA\xEE\xE3\xEE
\xEE\xE1\xFA\xE5\xEA
xF2\xE0 \xE4\xE0\xED\xED\xFB\xF5
       1
Error: Can't convert CHARACTER(1) to REAL(4) at (1)
check2.f90:6.23:

 aufun = '# ' // trim(temp) // ' #'
                      1
Error: 'string' argument of 'trim' intrinsic at (1) must be CHARACTER


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

* [Bug fortran/46588] Segfault on automatic function
  2010-11-21 12:59 [Bug fortran/46588] New: Segfault on automatic function oleg.steblev at gmail dot com
@ 2010-11-21 19:19 ` oleg.steblev at gmail dot com
  2010-11-21 19:39 ` kargl at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: oleg.steblev at gmail dot com @ 2010-11-21 19:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Oleh Steblev <oleg.steblev at gmail dot com> 2010-11-21 19:13:43 UTC ---
This chunk causes an error. Although PVF 10.8 passes this function.
    function aufun()
    character(len = *) aufun
    character(len = trim(aufun)) t 
    end


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

* [Bug fortran/46588] Segfault on automatic function
  2010-11-21 12:59 [Bug fortran/46588] New: Segfault on automatic function oleg.steblev at gmail dot com
  2010-11-21 19:19 ` [Bug fortran/46588] " oleg.steblev at gmail dot com
@ 2010-11-21 19:39 ` kargl at gcc dot gnu.org
  2010-11-22  8:11 ` [Bug fortran/46588] ICE with assumed character length function burnus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: kargl at gcc dot gnu.org @ 2010-11-21 19:39 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2010.11.21 19:18:49
                 CC|                            |kargl at gcc dot gnu.org
     Ever Confirmed|0                           |1
           Severity|enhancement                 |normal

--- Comment #2 from kargl at gcc dot gnu.org 2010-11-21 19:18:49 UTC ---
Reduced testcase.

function aufun(pm)
character(len = *) pm
character(len = *) aufun
character(len = len(aufun)) temp ! This is the problem.
aufun = 'hi'
end

I haven't checked if this is legal Fortran, but in any
event the compiler should not ICE.


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

* [Bug fortran/46588] ICE with assumed character length function
  2010-11-21 12:59 [Bug fortran/46588] New: Segfault on automatic function oleg.steblev at gmail dot com
  2010-11-21 19:19 ` [Bug fortran/46588] " oleg.steblev at gmail dot com
  2010-11-21 19:39 ` kargl at gcc dot gnu.org
@ 2010-11-22  8:11 ` burnus at gcc dot gnu.org
  2015-10-28 16:47 ` kargl at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2010-11-22  8:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
                 CC|                            |burnus at gcc dot gnu.org
            Summary|Segfault on automatic       |ICE with assumed character
                   |function                    |length function

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2010-11-22 08:09:07 UTC ---
(In reply to comment #2)
> Reduced testcase.
> 
> function aufun(pm)
> character(len = *) pm
> character(len = *) aufun
> character(len = len(aufun)) temp ! This is the problem.
> aufun = 'hi'
> end

Looks like legal Fortran of the ugly kind:
  character(len = *) pm
takes the length of the argument.

  character(len = *) aufun
takes the length of the definition; that's called "assumed character length
function", is obsolescence; cf. F2008 B.2.6. It runs against the spirit of
(modern) Fortran. Usage:
  function f()
    character(len=*) :: f
  end function
  subroutine test
    character(len=7) :: f
    print *, len(f())
  end
  subroutine test2
    character(len=1) :: f
    print *, len(f())
  end

  character(len = len(aufun)) temp
Also that line looks to be OK if the other lines are valid.


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

* [Bug fortran/46588] ICE with assumed character length function
  2010-11-21 12:59 [Bug fortran/46588] New: Segfault on automatic function oleg.steblev at gmail dot com
                   ` (2 preceding siblings ...)
  2010-11-22  8:11 ` [Bug fortran/46588] ICE with assumed character length function burnus at gcc dot gnu.org
@ 2015-10-28 16:47 ` kargl at gcc dot gnu.org
  2015-10-30 19:21 ` kargl at gcc dot gnu.org
  2015-10-30 19:30 ` kargl at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-10-28 16:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46588

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |kargl at gcc dot gnu.org

--- Comment #4 from kargl at gcc dot gnu.org ---
This appears to work now on trunk, but still
ICE's on 5-branch.  My recent patches for 
PR 67805 and friends may have fortuitously
fixed this PR.


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

* [Bug fortran/46588] ICE with assumed character length function
  2010-11-21 12:59 [Bug fortran/46588] New: Segfault on automatic function oleg.steblev at gmail dot com
                   ` (3 preceding siblings ...)
  2015-10-28 16:47 ` kargl at gcc dot gnu.org
@ 2015-10-30 19:21 ` kargl at gcc dot gnu.org
  2015-10-30 19:30 ` kargl at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-10-30 19:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46588

--- Comment #5 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Fri Oct 30 19:20:36 2015
New Revision: 229606

URL: https://gcc.gnu.org/viewcvs?rev=229606&root=gcc&view=rev
Log:
2015-10-30  Steven G. Kargl  <kargl@gcc.gnu.org>

        PR fortran/46588
        * gfortran.dg/pr46588.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/pr46588.f90
Modified:
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/46588] ICE with assumed character length function
  2010-11-21 12:59 [Bug fortran/46588] New: Segfault on automatic function oleg.steblev at gmail dot com
                   ` (4 preceding siblings ...)
  2015-10-30 19:21 ` kargl at gcc dot gnu.org
@ 2015-10-30 19:30 ` kargl at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-10-30 19:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46588

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |6.0

--- Comment #6 from kargl at gcc dot gnu.org ---
(In reply to kargl from comment #4)
> This appears to work now on trunk, but still
> ICE's on 5-branch.  My recent patches for 
> PR 67805 and friends may have fortuitously
> fixed this PR.

I've converted the code to a testcase and
committed it to trunk.  The bug is fixed in
5-branch, but Iwon't be committing the testcase
to the branhc.

Thanks for pointing out the bug.


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

end of thread, other threads:[~2015-10-30 19:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-21 12:59 [Bug fortran/46588] New: Segfault on automatic function oleg.steblev at gmail dot com
2010-11-21 19:19 ` [Bug fortran/46588] " oleg.steblev at gmail dot com
2010-11-21 19:39 ` kargl at gcc dot gnu.org
2010-11-22  8:11 ` [Bug fortran/46588] ICE with assumed character length function burnus at gcc dot gnu.org
2015-10-28 16:47 ` kargl at gcc dot gnu.org
2015-10-30 19:21 ` kargl at gcc dot gnu.org
2015-10-30 19:30 ` kargl 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).