public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/19195] New: gfortran: ICE in final_scan_insn, at final.c:1843
@ 2004-12-29 21:52 anlauf at hep dot tu-darmstadt dot de
  2004-12-29 22:01 ` [Bug fortran/19195] " pinskia at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: anlauf at hep dot tu-darmstadt dot de @ 2004-12-29 21:52 UTC (permalink / raw)
  To: gcc-bugs

Hi,

there must be some funny screw-up in the parser that shows up
under very special circumstances.  Compile the example below
with debugging.  There must *not* be any lines before the
"subroutine" in that file, otherwise the ICE does not show up.

% gfortran -c -g gfc-dbg-bug.f90
gfc-dbg-bug.f90: In function 'gfc_debug_bug':
gfc-dbg-bug.f90:-2: internal compiler error: in final_scan_insn, at final.c:1843

Here's the code:

subroutine gfc_debug_bug (n,m,k,ax,bx,c)
  implicit none
  integer :: n, m
  integer :: k(n+m)
  real    :: ax(:), bx(n), c(n+m)

  integer :: i
  real    :: f

  i = k(n)
  f = c(n)
  f = bx(n)
  f = ax(n)
end subroutine gfc_debug_bug
!
! Compile the above as follows:
! % gfortran -c -g gfc-dbg-bug.f90
! gfc-dbg-bug.f90: In function 'gfc_debug_bug':
! gfc-dbg-bug.f90:-2: internal compiler error: in final_scan_insn, at final.c:1843
!
! Adding a line (even an empty one) before "subroutine" resolves the bug...


Cheers,
-ha

-- 
           Summary: gfortran: ICE in final_scan_insn, at final.c:1843
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: anlauf at hep dot tu-darmstadt dot de
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i686-pc-linux-gnu


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


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

* [Bug fortran/19195] gfortran: ICE in final_scan_insn, at final.c:1843
  2004-12-29 21:52 [Bug fortran/19195] New: gfortran: ICE in final_scan_insn, at final.c:1843 anlauf at hep dot tu-darmstadt dot de
@ 2004-12-29 22:01 ` pinskia at gcc dot gnu dot org
  2004-12-29 22:08 ` pinskia at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-29 22:01 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|unknown                     |4.0.0


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


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

* [Bug fortran/19195] gfortran: ICE in final_scan_insn, at final.c:1843
  2004-12-29 21:52 [Bug fortran/19195] New: gfortran: ICE in final_scan_insn, at final.c:1843 anlauf at hep dot tu-darmstadt dot de
  2004-12-29 22:01 ` [Bug fortran/19195] " pinskia at gcc dot gnu dot org
@ 2004-12-29 22:08 ` pinskia at gcc dot gnu dot org
  2005-06-04 19:05 ` tobi at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-29 22:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-12-29 22:08 -------
Confirmed:
  [t.f : -2] return;


We are using the wrong line number for the return statement.
This usually means that cfun->function_end_locus is not set correctly.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |ice-on-valid-code
   Last reconfirmed|0000-00-00 00:00:00         |2004-12-29 22:08:20
               date|                            |


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


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

* [Bug fortran/19195] gfortran: ICE in final_scan_insn, at final.c:1843
  2004-12-29 21:52 [Bug fortran/19195] New: gfortran: ICE in final_scan_insn, at final.c:1843 anlauf at hep dot tu-darmstadt dot de
  2004-12-29 22:01 ` [Bug fortran/19195] " pinskia at gcc dot gnu dot org
  2004-12-29 22:08 ` pinskia at gcc dot gnu dot org
@ 2005-06-04 19:05 ` tobi at gcc dot gnu dot org
  2005-06-04 19:51 ` tobi at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: tobi at gcc dot gnu dot org @ 2005-06-04 19:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tobi at gcc dot gnu dot org  2005-06-04 19:04 -------
It looks like I made a mistake there, the original code had a +1 in
gfc_set_backend_locus, as can be seeing by diffing rev 1.4 against rev 1.5.  I
can't remember what all this was about at the moment, so I don't know what's right.

Index: trans.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/trans.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -p -r1.4 -r1.5
--- trans.c     14 May 2004 13:00:04 -0000      1.4
+++ trans.c     15 May 2004 17:31:32 -0000      1.5
@@ -414,8 +414,9 @@ gfc_add_block_to_block (stmtblock_t * bl
 void
 gfc_get_backend_locus (locus * loc)
 {
-  loc->line = input_line - 1;
-  loc->file = gfc_current_backend_file;
+  loc->lb = gfc_getmem (sizeof (gfc_linebuf));
+  loc->lb->linenum = input_line - 1;
+  loc->lb->file = gfc_current_backend_file;
 }


@@ -424,9 +425,9 @@ gfc_get_backend_locus (locus * loc)
 void
 gfc_set_backend_locus (locus * loc)
 {
-  input_line = loc->line + 1;
-  gfc_current_backend_file = loc->file;
-  input_filename = loc->file->filename;
+  input_line = loc->lb->linenum;
+  gfc_current_backend_file = loc->lb->file;
+  input_filename = loc->lb->file->filename;
 }

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tobi at gcc dot gnu dot org


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


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

* [Bug fortran/19195] gfortran: ICE in final_scan_insn, at final.c:1843
  2004-12-29 21:52 [Bug fortran/19195] New: gfortran: ICE in final_scan_insn, at final.c:1843 anlauf at hep dot tu-darmstadt dot de
                   ` (2 preceding siblings ...)
  2005-06-04 19:05 ` tobi at gcc dot gnu dot org
@ 2005-06-04 19:51 ` tobi at gcc dot gnu dot org
  2005-06-04 21:57 ` tobi at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: tobi at gcc dot gnu dot org @ 2005-06-04 19:51 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tobi at gcc dot gnu dot org  2005-06-04 19:51 -------
Hm, lb->linenum should start counting from line 1, so I've no idea what the
original code was trying to do.

-- 


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


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

* [Bug fortran/19195] gfortran: ICE in final_scan_insn, at final.c:1843
  2004-12-29 21:52 [Bug fortran/19195] New: gfortran: ICE in final_scan_insn, at final.c:1843 anlauf at hep dot tu-darmstadt dot de
                   ` (3 preceding siblings ...)
  2005-06-04 19:51 ` tobi at gcc dot gnu dot org
@ 2005-06-04 21:57 ` tobi at gcc dot gnu dot org
  2005-06-04 22:05 ` schnetter at aei dot mpg dot de
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: tobi at gcc dot gnu dot org @ 2005-06-04 21:57 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tobi at gcc dot gnu dot org  2005-06-04 21:56 -------
I think this is the right thing to do, but I'm not sure it's the only bug.  The
line number given in the ICE is minus two, but this patch only fixes an off-by-one.

2005-06-04  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
        Erik Schnetter  <schnetter@aei.mpg.de>

Index: trans.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/trans.c,v
retrieving revision 1.24
diff -u -p -r1.24 trans.c
--- trans.c     26 May 2005 18:36:10 -0000      1.24
+++ trans.c     4 Jun 2005 21:53:50 -0000
@@ -437,9 +437,9 @@ gfc_get_backend_locus (locus * loc)
 {
   loc->lb = gfc_getmem (sizeof (gfc_linebuf));
 #ifdef USE_MAPPED_LOCATION
-  loc->lb->location = input_location; /* FIXME adjust?? */
+  loc->lb->location = input_location;
 #else
-  loc->lb->linenum = input_line - 1;
+  loc->lb->linenum = input_line;
 #endif
   loc->lb->file = gfc_current_backend_file;
 }

(I've also added Erik to the CC list, as he showed some interest in this bug)

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schnetter at aei dot mpg dot
                   |                            |de


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


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

* [Bug fortran/19195] gfortran: ICE in final_scan_insn, at final.c:1843
  2004-12-29 21:52 [Bug fortran/19195] New: gfortran: ICE in final_scan_insn, at final.c:1843 anlauf at hep dot tu-darmstadt dot de
                   ` (4 preceding siblings ...)
  2005-06-04 21:57 ` tobi at gcc dot gnu dot org
@ 2005-06-04 22:05 ` schnetter at aei dot mpg dot de
  2005-06-04 22:06 ` tobi at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: schnetter at aei dot mpg dot de @ 2005-06-04 22:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From schnetter at aei dot mpg dot de  2005-06-04 22:05 -------
I had a case where the line number was set to -123 in the end.  With this 
patch this works now. 
 
I assumed that the get/set routines would be called repeatedly, and the line 
number is reduced by one each time. 
 

-- 


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


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

* [Bug fortran/19195] gfortran: ICE in final_scan_insn, at final.c:1843
  2004-12-29 21:52 [Bug fortran/19195] New: gfortran: ICE in final_scan_insn, at final.c:1843 anlauf at hep dot tu-darmstadt dot de
                   ` (5 preceding siblings ...)
  2005-06-04 22:05 ` schnetter at aei dot mpg dot de
@ 2005-06-04 22:06 ` tobi at gcc dot gnu dot org
  2005-06-04 22:08 ` tobi at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: tobi at gcc dot gnu dot org @ 2005-06-04 22:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tobi at gcc dot gnu dot org  2005-06-04 22:06 -------
*** Bug 20829 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |federico dot carminati at
                   |                            |cern dot ch


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


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

* [Bug fortran/19195] gfortran: ICE in final_scan_insn, at final.c:1843
  2004-12-29 21:52 [Bug fortran/19195] New: gfortran: ICE in final_scan_insn, at final.c:1843 anlauf at hep dot tu-darmstadt dot de
                   ` (6 preceding siblings ...)
  2005-06-04 22:06 ` tobi at gcc dot gnu dot org
@ 2005-06-04 22:08 ` tobi at gcc dot gnu dot org
  2005-06-04 22:21 ` cvs-commit at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: tobi at gcc dot gnu dot org @ 2005-06-04 22:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tobi at gcc dot gnu dot org  2005-06-04 22:08 -------
There's definitely something wrong if we call this pair of functions 123 times
on the same function :-)  The patch also fixes PR 20829, so I think I'll post it
to the list and commit it, either as obvious or as approved version of your
patch :-)

-- 


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


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

* [Bug fortran/19195] gfortran: ICE in final_scan_insn, at final.c:1843
  2004-12-29 21:52 [Bug fortran/19195] New: gfortran: ICE in final_scan_insn, at final.c:1843 anlauf at hep dot tu-darmstadt dot de
                   ` (7 preceding siblings ...)
  2005-06-04 22:08 ` tobi at gcc dot gnu dot org
@ 2005-06-04 22:21 ` cvs-commit at gcc dot gnu dot org
  2005-06-04 22:23 ` tobi at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-06-04 22:21 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-06-04 22:21 -------
Subject: Bug 19195

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	tobi@gcc.gnu.org	2005-06-04 22:20:58

Modified files:
	gcc/fortran    : ChangeLog trans.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gfortran.dg: debug_1.f90 

Log message:
	fortran/
	2005-06-04  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
	Erik Schnetter  <schnetter@aei.mpg.de>
	
	PR fortran/19195
	* trans.c (gfc_get_backend_locus): Remove unnecessary adjustment,
	remove FIXME comment.
	
	testsuite/
	2005-06-04  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
	
	PR fortran/19195
	* gfortran.dg/debug_1.f90: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&r1=1.453&r2=1.454
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans.c.diff?cvsroot=gcc&r1=1.24&r2=1.25
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5593&r2=1.5594
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/debug_1.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


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


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

* [Bug fortran/19195] gfortran: ICE in final_scan_insn, at final.c:1843
  2004-12-29 21:52 [Bug fortran/19195] New: gfortran: ICE in final_scan_insn, at final.c:1843 anlauf at hep dot tu-darmstadt dot de
                   ` (8 preceding siblings ...)
  2005-06-04 22:21 ` cvs-commit at gcc dot gnu dot org
@ 2005-06-04 22:23 ` tobi at gcc dot gnu dot org
  2005-06-04 22:43 ` cvs-commit at gcc dot gnu dot org
  2005-06-04 22:43 ` tobi at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: tobi at gcc dot gnu dot org @ 2005-06-04 22:23 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tobi at gcc dot gnu dot org  2005-06-04 22:23 -------
Fixed. Thanks, Erik.

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


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


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

* [Bug fortran/19195] gfortran: ICE in final_scan_insn, at final.c:1843
  2004-12-29 21:52 [Bug fortran/19195] New: gfortran: ICE in final_scan_insn, at final.c:1843 anlauf at hep dot tu-darmstadt dot de
                   ` (10 preceding siblings ...)
  2005-06-04 22:43 ` cvs-commit at gcc dot gnu dot org
@ 2005-06-04 22:43 ` tobi at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: tobi at gcc dot gnu dot org @ 2005-06-04 22:43 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.0.1


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


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

* [Bug fortran/19195] gfortran: ICE in final_scan_insn, at final.c:1843
  2004-12-29 21:52 [Bug fortran/19195] New: gfortran: ICE in final_scan_insn, at final.c:1843 anlauf at hep dot tu-darmstadt dot de
                   ` (9 preceding siblings ...)
  2005-06-04 22:23 ` tobi at gcc dot gnu dot org
@ 2005-06-04 22:43 ` cvs-commit at gcc dot gnu dot org
  2005-06-04 22:43 ` tobi at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-06-04 22:43 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-06-04 22:43 -------
Subject: Bug 19195

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	tobi@gcc.gnu.org	2005-06-04 22:43:17

Modified files:
	gcc/fortran    : ChangeLog trans.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gfortran.dg: debug_1.f90 

Log message:
	fortran/
	2005-06-04  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
	Erik Schnetter  <schnetter@aei.mpg.de>
	
	PR fortran/19195
	* trans.c (gfc_get_backend_locus): Remove unnecessary adjustment,
	remove FIXME comment.
	testsuite/
	2005-06-04  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
	
	PR fortran/19195
	* gfortran.dg/debug_1.f90: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.335.2.65&r2=1.335.2.66
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.21&r2=1.21.10.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.227&r2=1.5084.2.228
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/debug_1.f90.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1



-- 


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


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

end of thread, other threads:[~2005-06-04 22:43 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-29 21:52 [Bug fortran/19195] New: gfortran: ICE in final_scan_insn, at final.c:1843 anlauf at hep dot tu-darmstadt dot de
2004-12-29 22:01 ` [Bug fortran/19195] " pinskia at gcc dot gnu dot org
2004-12-29 22:08 ` pinskia at gcc dot gnu dot org
2005-06-04 19:05 ` tobi at gcc dot gnu dot org
2005-06-04 19:51 ` tobi at gcc dot gnu dot org
2005-06-04 21:57 ` tobi at gcc dot gnu dot org
2005-06-04 22:05 ` schnetter at aei dot mpg dot de
2005-06-04 22:06 ` tobi at gcc dot gnu dot org
2005-06-04 22:08 ` tobi at gcc dot gnu dot org
2005-06-04 22:21 ` cvs-commit at gcc dot gnu dot org
2005-06-04 22:23 ` tobi at gcc dot gnu dot org
2005-06-04 22:43 ` cvs-commit at gcc dot gnu dot org
2005-06-04 22:43 ` tobi at gcc dot gnu dot 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).