public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/42996] New: Incorrect length returned from get_command_argument intrinsic
@ 2010-02-08 10:44 ian_harvey at bigpond dot com
2010-02-08 10:48 ` [Bug libfortran/42996] " ian_harvey at bigpond dot com
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: ian_harvey at bigpond dot com @ 2010-02-08 10:44 UTC (permalink / raw)
To: gcc-bugs
According to the F2003 standard, the LENGTH argument does "not consider any
possible truncation or padding in assigning the command argument value to the
VALUE argument" (13.7.42). However, gfortran appears to use the minimum of the
length of the VALUE argument (if present) and the length of the command
argument.
(svn revision 156557)
--
Summary: Incorrect length returned from get_command_argument
intrinsic
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libfortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ian_harvey at bigpond dot com
GCC build triplet: i686-pc-mingw32
GCC host triplet: i686-pc-mingw32
GCC target triplet: i686-pc-mingw32
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42996
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libfortran/42996] Incorrect length returned from get_command_argument intrinsic
2010-02-08 10:44 [Bug libfortran/42996] New: Incorrect length returned from get_command_argument intrinsic ian_harvey at bigpond dot com
@ 2010-02-08 10:48 ` ian_harvey at bigpond dot com
2010-02-08 13:19 ` burnus at gcc dot gnu dot org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: ian_harvey at bigpond dot com @ 2010-02-08 10:48 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from ian_harvey at bigpond dot com 2010-02-08 10:48 -------
Created an attachment (id=19819)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19819&action=view)
Simple test case
Call the resulting program with an argument longer than one character.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42996
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libfortran/42996] Incorrect length returned from get_command_argument intrinsic
2010-02-08 10:44 [Bug libfortran/42996] New: Incorrect length returned from get_command_argument intrinsic ian_harvey at bigpond dot com
2010-02-08 10:48 ` [Bug libfortran/42996] " ian_harvey at bigpond dot com
@ 2010-02-08 13:19 ` burnus at gcc dot gnu dot org
2010-02-09 17:05 ` burnus at gcc dot gnu dot org
2010-02-09 17:07 ` burnus at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-02-08 13:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from burnus at gcc dot gnu dot org 2010-02-08 13:19 -------
Confirm - I get for "./a.out test" the following result.
Current (gfortran):
With no value, length was:4 and status:0
With LEN=1 value, length was:1 and status:-1 <<<<< Bad: len = 1
With LEN=10 value, length was:4 and status:0
Expected (NAG f95, ifort):
With no value, length was:4 and status:0
With LEN=1 value, length was:4 and status:-1 <<<<< OK: len = 4
With LEN=10 value, length was:4 and status:0
By the way, the manual is correct:
http://gcc.gnu.org/onlinedocs/gfortran/GET_005fCOMMAND_005fARGUMENT.html
Draft patch:
diff --git a/libgfortran/intrinsics/args.c b/libgfortran/intrinsics/args.c
index 7187bec..83a0502 100644
--- a/libgfortran/intrinsics/args.c
+++ b/libgfortran/intrinsics/args.c
@@ -147,11 +147,9 @@ get_command_argument_i4 (GFC_INTEGER_4 *number, char
*value,
if (value != NULL && stat_flag != GFC_GC_FAILURE)
{
if (arglen > value_len)
- {
- arglen = value_len;
stat_flag = GFC_GC_VALUE_TOO_SHORT;
- }
- memcpy (value, argv[*number], arglen);
+
+ memcpy (value, argv[*number], arglen > value_len ? value_len : arglen);
}
if (length != NULL)
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2010-02-08 13:19:24
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42996
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libfortran/42996] Incorrect length returned from get_command_argument intrinsic
2010-02-08 10:44 [Bug libfortran/42996] New: Incorrect length returned from get_command_argument intrinsic ian_harvey at bigpond dot com
2010-02-08 10:48 ` [Bug libfortran/42996] " ian_harvey at bigpond dot com
2010-02-08 13:19 ` burnus at gcc dot gnu dot org
@ 2010-02-09 17:05 ` burnus at gcc dot gnu dot org
2010-02-09 17:07 ` burnus at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-02-09 17:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from burnus at gcc dot gnu dot org 2010-02-09 17:05 -------
Subject: Bug 42996
Author: burnus
Date: Tue Feb 9 17:04:57 2010
New Revision: 156630
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156630
Log:
2010-02-09 Tobias Burnus <burnus@net-b.de>
PR fortran/42996
* intrinsics/args.c (get_command_argument_i4): Always return
commandline-argument length for length parameter.
Modified:
trunk/libgfortran/ChangeLog
trunk/libgfortran/intrinsics/args.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42996
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libfortran/42996] Incorrect length returned from get_command_argument intrinsic
2010-02-08 10:44 [Bug libfortran/42996] New: Incorrect length returned from get_command_argument intrinsic ian_harvey at bigpond dot com
` (2 preceding siblings ...)
2010-02-09 17:05 ` burnus at gcc dot gnu dot org
@ 2010-02-09 17:07 ` burnus at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-02-09 17:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from burnus at gcc dot gnu dot org 2010-02-09 17:07 -------
FIXED on the trunk (4.5).
Thanks for the bug report!
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42996
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-02-09 17:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-08 10:44 [Bug libfortran/42996] New: Incorrect length returned from get_command_argument intrinsic ian_harvey at bigpond dot com
2010-02-08 10:48 ` [Bug libfortran/42996] " ian_harvey at bigpond dot com
2010-02-08 13:19 ` burnus at gcc dot gnu dot org
2010-02-09 17:05 ` burnus at gcc dot gnu dot org
2010-02-09 17:07 ` burnus 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).