User account creation filtered due to spam.

Bug 6367 - multiple repeat counts confuse namelist read into array
Summary: multiple repeat counts confuse namelist read into array
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libf2c (show other bugs)
Version: 2.96
: P3 normal
Target Milestone: ---
Assignee: Toon Moene
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-04-18 13:26 UTC by mcdonald
Modified: 2003-09-23 22:14 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mcdonald 2002-04-18 13:26:01 UTC
A one-dimensional array assigned values by a namelist read
statement receives those values in the wrong array elements
when the namelist input contains an array assignment with
(1) an array subscript and
(2) more than one repeat count specifier with dissimilar
    counts.

I have produced the same incorrect result using g77 3.1,
f2c, and g77 under cygwin/Win2000.  Other Fortran
compilers not using f2c's library (such as Lahey Fortran
95 ver.6.1 under RH Linux 7.2) yield the correct result.

Note - this bug is similar to but not the same as the
namelist repeat count bug fixed 1999-jun-27; from
www.netlib.org f2c "changes" list:
  Sun Jun 27 22:05:47 EDT 1999
   libf2c.zip, libi77: rsne.c: fix bug in namelist input:
  a misplaced increment could cause wrong array elements
  to be assigned; e.g.,
  "&input k(5)=10*1 &end" assigned k(5) and k(15 .. 23).

Release:
gcc 2.96

Environment:
RedHat Linux 7.2

How-To-Repeat:
Compile this 10-line Fortran77 program:

      program testnl
c
      dimension a(10)
      namelist /nl/ a
      data a / 10 * 0.0 /
c
      read(5,nl)
      write(6,*) a
c
      end

Now run the program with this input data,

&nl a(2) = 3*1.0, 2*2.0, 3*3.0 /

and you will probably see this incorrect result:

  0.  1.  1.  1.  2.  3.  3.  0.  0.  0.

The correct result should be

  0.  1.  1.  1.  2.  2.  3.  3.  3.  0.
Comment 1 Toon Moene 2002-04-19 15:00:01 UTC
Responsible-Changed-From-To: unassigned->toon
Responsible-Changed-Why: Fortran maintainer
Comment 2 Toon Moene 2002-04-19 15:00:01 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Fails at least from GCC-2.95.2 onwards.
    Added test suite entry 6367.f for it.
Comment 3 Toon Moene 2002-08-31 07:51:15 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed for GCC/g77 - 3.3
Comment 4 mcdonald 2002-09-04 12:00:41 UTC
From: Jim McDonald <mcdonald@mmace.nrl.navy.mil>
To: toon@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org,
        mcdonald@mmace.nrl.navy.mil, gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: libf2c/6367 bugfix - thanks
Date: Wed, 4 Sep 2002 12:00:41 -0400 (EDT)

 Toon writes:
 > Synopsis: multiple repeat counts confuse namelist read into array
 > 
 > State-Changed-From-To: analyzed->closed
 > State-Changed-By: toon
 > State-Changed-When: Sat Aug 31 07:51:15 2002
 > State-Changed-Why:
 >     Fixed for GCC/g77 - 3.3
 Thanks for fixing this bug.  I haven't tried out the new code yet, but I
 assume I can download a gcc 3.3 distro from some convenient source.
 I hope the fixes propagate to netlib soon.
 - Jim McDonald
   Naval Research Lab, Code 6841
   (202) 404-6936, fax 767-1280
   James.A.McDonald@nrl.navy.mil