This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/31764] NEW_LINE with array argument
- From: "fxcoudert at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 4 May 2007 11:52:18 -0000
- Subject: [Bug fortran/31764] NEW_LINE with array argument
- References: <bug-31764-13648@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from fxcoudert at gcc dot gnu dot org 2007-05-04 12:52 -------
(Side note: NEW_LINE is not an elemental function. It can be used with an array
argument, but it's different from being elemental.)
As for the bug itself, there's no reason that the argument to NEW_LINE should
be constant: the only requirement is that it's of character kind (all that is
used in NEW_LINE is the character kind, which is always known at compile-time).
So, the following patch fixes it, and I believe it does the right thing:
Index: simplify.c
===================================================================
--- simplify.c (revision 124415)
+++ simplify.c (working copy)
@@ -2641,13 +2641,8 @@ gfc_simplify_new_line (gfc_expr *e)
{
gfc_expr *result;
- if (e->expr_type != EXPR_CONSTANT)
- return NULL;
-
result = gfc_constant_result (BT_CHARACTER, e->ts.kind, &e->where);
-
result->value.character.string = gfc_getmem (2);
-
result->value.character.length = 1;
result->value.character.string[0] = '\n';
result->value.character.string[1] = '\0'; /* For debugger */
This patch is donated to whomever has time to confirm that it does what it
should, that it conforms to the standard and that it regtests. (I'll take care
of it next week if noone has time before then.) The following testcase now
passes:
$ cat a.f90
character(len=10) :: a1
character(len=10) :: a2(2)
character(len=10), parameter :: a3 = "1234567890"
character(len=10), parameter :: a4(2) = "1234567890"
character(len=10), parameter :: a5(2) = repeat("1234567890",2)
print *, ichar(new_line(a1))
print *, ichar(new_line(a2))
print *, ichar(new_line(a3))
print *, ichar(new_line(a4))
print *, ichar(new_line(a5))
end
$ gfortran a.f90 && ./a.out
10
10
10
10
10
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fxcoudert at gcc dot gnu dot
| |org
Keywords| |patch
Known to fail| |4.3.0
Last reconfirmed|2007-04-30 15:43:12 |2007-05-04 12:52:17
date| |
Summary|[f2003] ice in new_line if |NEW_LINE with array argument
|used as elemental function |
Target Milestone|--- |4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31764