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]

Re: g77-0.5.22 possible bug (also in egcs).


Dag,

Your sample code (reproduced below for the egcs-bugs list) also  
kills g77 on my m68k-next-nextstep3 system (both the released  
g77-0.5.22+gcc-2.7.2.3 and a recent cvs snapshot of egcs):

[ the error was reported for i586-unknown-linux-gnulibc1 ]

The code:

c##################################################
      character*80 function nxtlin(lun,ierr,itok)
c##################################################
      character onechr*1,twochr*2,thrchr*3
c
      itok=0
      do while (.true.)
         read (lun,'(a)',iostat=ierr) nxtlin
         if (nxtlin(1:1).ne.'#') then
            ito=0
            do 10 it=1,79
               if (nxtlin(it:it).ne.' ' .and. nxtlin(it+1:it+1).eq.' ')
     $              then
c-----A token found:
c-----Check if token contains an asterisk ==> free format reading
                  itast=0
                  itstrt=0
                  do itt=ito+1,it
                     if (nxtlin(itt:itt).eq.'*') itast=itt
                  enddo
c-----Find beginning of non-blank part of token
                  itstrt=ito+1
                  do while (nxtlin(itstrt:itstrt).eq.' ')
                     itstrt=itstrt+1
                  enddo
                  if (itast.gt.0) then
                     nchrs=itast-itstrt
                     if (nchrs.eq.1) then
                        onechr=nxtlin(itstrt:itstrt)
                        read (onechr,*) itokn
                     elseif (nchrs.eq.2) then
                        twochr=nxtlin(itstrt:itstrt+1)
                        read (twochr,*) itokn
                     elseif (nchrs.eq.3) then
                        thrchr=nxtlin(itstrt:itstrt+2)
                        read (thrchr,*) itokn
                     elseif (nchrs.eq.4) then
                        thrchr=nxtlin(itstrt:itstrt+3)
                        read (thrchr,*) itokn
                     endif
c                    print *,'Starinput:',nchrs,itok,itast,itstrt
                     itok=itok+itokn
                  else
                     itok=itok+1
                  endif
                  ito=it+1
               endif
 10         continue
            return
         endif
      enddo
c
      return
      end

Gdb traceback with egcs version:

(gdb) dir ../compilers/snapshots/egcs/gcc
Source directories searched:  
/Users/toon/Unix/src/../compilers/snapshots/egcs/gcc:/usr/snp/lib/gcc-lib/m68k-next-nextstep3/egcs-2.91.19:$cdir:$cwd
(gdb) run  wennerberg.f -fset-g77-defaults -quiet -dumpbase  
wennerberg.f -O2 -W -Wall -version -fversion -o /usr/tmp/cc028904.s
Starting program:  
/usr/snp/lib/gcc-lib/m68k-next-nextstep3/egcs-2.91.19/f771  
wennerberg.f -fset-g77-defaults -quiet -dumpbase wennerberg.f -O2 -W  
-Wall -version -fversion -o /usr/tmp/cc028904.s
GNU F77 version egcs-2.91.19 980404 (gcc2 ss-980401 experimental)  
(m68k-next-nextstep3) compiled by GNU C version egcs-2.91.19 980404  
(gcc2 ss-980401 experimental).
GNU Fortran Front End version 0.5.22-release
Program generated(1): Memory access exception on address 0x0  
(protection failure).
Reading in symbols for ../../egcs/gcc/loop.c...done.
skip_consec_insns (insn=0x0, count=1) at ../../egcs/gcc/loop.c:1246
Source file is more recent than executable.
1246          while (GET_CODE (insn) == NOTE);
(gdb) list
1241          if (GET_CODE (insn) != NOTE
1242              && (temp = find_reg_note (insn, REG_LIBCALL,  
NULL_RTX)))
1243            insn = XEXP (temp, 0);
1244
1245          do insn = NEXT_INSN (insn);
1246          while (GET_CODE (insn) == NOTE);
1247        }
1248
1249      return insn;
1250    }
(gdb) bt
Reading in symbols for ../../egcs/gcc/toplev.c...done.
Reading in symbols for ../../egcs/gcc/f/com.c...done.
Reading in symbols for ../../egcs/gcc/f/std.c...done.
Reading in symbols for ../../egcs/gcc/f/stc.c...done.
Reading in symbols for ../../egcs/gcc/f/stb.c...done.
Reading in symbols for ../../egcs/gcc/f/sta.c...done.
Reading in symbols for ../../egcs/gcc/f/lex.c...done.
Reading in symbols for ../../egcs/gcc/f/top.c...done.
Reading in symbols for ../../egcs/gcc/f/parse.c...done.
#0  skip_consec_insns (insn=0x0, count=1) at ../../egcs/gcc/loop.c:1246
#1  0xda552 in scan_loop (loop_start=0x183690, end=0x1b36ea,  
nregs=154, unroll_p=0) at ../../egcs/gcc/loop.c:900
#2  0xd9d2c in loop_optimize (f=0x182844, dumpfile=0x0, unroll_p=0)  
at ../../egcs/gcc/loop.c:521
#3  0x72176 in rest_of_compilation (decl=void) at  
../../egcs/gcc/toplev.c:3278
#4  0x14f3a in finish_function (nested=0) at ../../egcs/gcc/f/com.c:14233
#5  0x12010 in ffecom_finish_progunit () at ../../egcs/gcc/f/com.c:11665
#6  0x58c3c in ffestd_exec_end () at ../../egcs/gcc/f/std.c:1505
#7  0x505c2 in ffestc_shriek_function_ (ok=true) at  
../../egcs/gcc/f/stc.c:4759
#8  0x570ac in ffestc_R1221 (name=void) at ../../egcs/gcc/f/stc.c:12328
#9  0x50e6a in ffestc_end () at ../../egcs/gcc/f/stc.c:5628
#10 0x3d934 in ffestb_end3_ (t=void) at ../../egcs/gcc/f/stb.c:3207
#11 0x3d644 in ffestb_end (t=void) at ../../egcs/gcc/f/stb.c:2986
#12 0x3ab20 in ffesta_second_ (t=void) at ../../egcs/gcc/f/sta.c:1358
#13 0x362ae in ffelex_send_token_ () at ../../egcs/gcc/f/lex.c:1652
#14 0x35248 in ffelex_finish_statement_ () at ../../egcs/gcc/f/lex.c:973
#15 0x37318 in ffelex_file_fixed (wf=void, f=0xb7c32) at  
../../egcs/gcc/f/lex.c:2994
#16 0x6f2ee in ffe_file (wf=void, f=0x401003c) at  
../../egcs/gcc/f/top.c:555
#17 0x3943e in yyparse () at ../../egcs/gcc/f/parse.c:74
#18 0x71594 in compile_file (name=0x401003c "") at  
../../egcs/gcc/toplev.c:2544
#19 0x7350a in main (argc=13, argv=0x70a26, envp=0x3fffc54) at  
../../egcs/gcc/toplev.c:4361
(gdb)

Note that skip_consec_insns is called from this piece of code in  
scan_loop:

                  /* It is possible for the first instruction to have a
                     REG_EQUAL note but a non-invariant SET_SRC, so  
we must
                     remember the status of the first instruction in case
                     the last instruction doesn't have a REG_EQUAL  
note.  */
                  m->move_insn_first = m->move_insn;

                  /* Skip this insn, not checking REG_LIBCALL notes.  */
                  p = next_nonnote_insn (p);
                  /* Skip the consecutive insns, if there are any.  */
                  p = skip_consec_insns (p, m->consec);
                  /* Back up to the last insn of the consecutive  
group.  */
                  p = prev_nonnote_insn (p);

It seems that this sequence was never written with the expectation  
that next_nonnote_insn could fail (return 0).  Is that correct ?

Hope someone can shed some light on this,
Toon.


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