Bug 20085 - iargc returns wrong count for number of program arguments
iargc returns wrong count for number of program arguments
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: libfortran
4.0.0
: P2 normal
: 4.0.0
Assigned To: Not yet assigned to anyone
: patch
: 20246 (view as bug list)
Depends on:
Blocks: 19292
  Show dependency treegraph
 
Reported: 2005-02-19 17:56 UTC by Dale Ranta
Modified: 2005-02-28 13:45 UTC (History)
2 users (show)

See Also:
Host: powerpc-apple-darwin7.8.0
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-02-19 18:07:02


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dale Ranta 2005-02-19 17:56:29 UTC
Function iargc return the wrong argument count on the Macintosh. It returns 1
when it should be zero etc... -

[dir:~/tests/gfortran] dir% gfortran -o mopen mopen.f
[dir:~/tests/gfortran] dir% mopen
           1                                                                   
             
STOP 0
[dir:~/tests/gfortran] dir% mopen one
           1 one                                                               
             
           2                                                                   
             
STOP 0
[dir:~/tests/gfortran] dir% cat mopen.f
      program mopen
      character*80 c
      integer i,iargc
      iargs=iargc()
      do 10 i=1,iargs
      call getarg(i,c)
      write(*,*)i,c
   10 continue
      stop
      end      
[dir:~/tests/gfortran] dir%
Comment 1 Andrew Pinski 2005-02-19 18:07:02 UTC
Confirmed, just an off by one error as we are counting the program name (aka argument 0).
Comment 2 Steve Kargl 2005-02-20 05:00:09 UTC
Patch is here

http://gcc.gnu.org/ml/gcc-patches/2005-02/msg01148.html
Comment 3 CVS Commits 2005-02-20 15:24:06 UTC
Subject: Bug 20085

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	kargl@gcc.gnu.org	2005-02-20 15:24:02

Modified files:
	libgfortran    : ChangeLog 
	libgfortran/intrinsics: args.c 

Log message:
	PR 20085
	* intrinsic/args.c (iargc): Off by 1.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&r1=1.158&r2=1.159
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/intrinsics/args.c.diff?cvsroot=gcc&r1=1.5&r2=1.6

Comment 4 kargl 2005-02-20 15:37:20 UTC
Patch applied.
Comment 5 Andrew Pinski 2005-02-28 13:45:58 UTC
*** Bug 20246 has been marked as a duplicate of this bug. ***