public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/30278] New: Inconsistencies with backslash handling
@ 2006-12-22 15:13 tobi at gcc dot gnu dot org
2006-12-23 12:12 ` [Bug fortran/30278] " steven at gcc dot gnu dot org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: tobi at gcc dot gnu dot org @ 2006-12-22 15:13 UTC (permalink / raw)
To: gcc-bugs
A testcase provided by Eef van Beveren, notice the difference between the
handling of backslash in the format string and in the regular string:
schluter@pcl247d:~/src> cat backslash.f
call wrt('\backslash')
call wrt('\\backslash')
write (*,100)
write (*,200)
stop
100 format ('\backslash now results in \backslash')
200 format ('\\backslash now results in \\backslash')
end
subroutine wrt(a)
character*(*) a
lena = len(a)
write(*,*) 'results in: ', a(1:lena)
return
end
schluter@pcl247d:~/src> gfortran backslash.f
schluter@pcl247d:~/src> ./a.out
results in:ackslash
results in: \backslash
\backslash now results in \backslash
\\backslash now results in \\backslash
schluter@pcl247d:~/src> gfortran -fno-backslash backslash.f
schluter@pcl247d:~/src> ./a.out
results in: \backslash
results in: \\backslash
\backslash now results in \backslash
\\backslash now results in \\backslash
schluter@pcl247d:~/src> g77 backslash.f
schluter@pcl247d:~/src> ./a.out
results in:ackslash
results in: \backslash
ackslash now results inackslash
\backslash now results in \backslash
schluter@pcl247d:~/src>
--
Summary: Inconsistencies with backslash handling
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tobi at gcc dot gnu dot org
OtherBugsDependingO 19292
nThis:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30278
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/30278] Inconsistencies with backslash handling
2006-12-22 15:13 [Bug fortran/30278] New: Inconsistencies with backslash handling tobi at gcc dot gnu dot org
@ 2006-12-23 12:12 ` steven at gcc dot gnu dot org
2006-12-23 12:19 ` steven at gcc dot gnu dot org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: steven at gcc dot gnu dot org @ 2006-12-23 12:12 UTC (permalink / raw)
To: gcc-bugs
--
steven 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 |2006-12-23 12:12:23
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30278
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/30278] Inconsistencies with backslash handling
2006-12-22 15:13 [Bug fortran/30278] New: Inconsistencies with backslash handling tobi at gcc dot gnu dot org
2006-12-23 12:12 ` [Bug fortran/30278] " steven at gcc dot gnu dot org
@ 2006-12-23 12:19 ` steven at gcc dot gnu dot org
2006-12-23 12:43 ` steven at gcc dot gnu dot org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: steven at gcc dot gnu dot org @ 2006-12-23 12:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from steven at gcc dot gnu dot org 2006-12-23 12:19 -------
This is what g77 outputs for this test case:
results in:ackslash
results in: \backslash
ackslash now results inackslash
\backslash now results in \backslash
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30278
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/30278] Inconsistencies with backslash handling
2006-12-22 15:13 [Bug fortran/30278] New: Inconsistencies with backslash handling tobi at gcc dot gnu dot org
2006-12-23 12:12 ` [Bug fortran/30278] " steven at gcc dot gnu dot org
2006-12-23 12:19 ` steven at gcc dot gnu dot org
@ 2006-12-23 12:43 ` steven at gcc dot gnu dot org
2006-12-23 12:52 ` steven at gcc dot gnu dot org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: steven at gcc dot gnu dot org @ 2006-12-23 12:43 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from steven at gcc dot gnu dot org 2006-12-23 12:42 -------
I suspect that the problem is some difference between the front end and library
FORMAT parsers.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30278
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/30278] Inconsistencies with backslash handling
2006-12-22 15:13 [Bug fortran/30278] New: Inconsistencies with backslash handling tobi at gcc dot gnu dot org
` (2 preceding siblings ...)
2006-12-23 12:43 ` steven at gcc dot gnu dot org
@ 2006-12-23 12:52 ` steven at gcc dot gnu dot org
2006-12-23 13:12 ` tobi at gcc dot gnu dot org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: steven at gcc dot gnu dot org @ 2006-12-23 12:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from steven at gcc dot gnu dot org 2006-12-23 12:52 -------
This not-for-including patch shows that we should match "\\" in io.c and treat
it as a single '\\' character. This is what g77 appears to do, too.
Index: io.c
===================================================================
--- io.c (revision 120167)
+++ io.c (working copy)
@@ -905,6 +905,24 @@ gfc_match_format (void)
check_format (); /* Guaranteed to succeed */
gfc_match_eos (); /* Guaranteed to succeed */
+ {
+ char c1, c2;
+ int i, j;
+ int len = e->value.character.length;
+ for (i = 0; i < len - 1; ++i)
+ {
+ c1 = e->value.character.string[i];
+ c2 = e->value.character.string[i + 1];
+ if (c1 == '\\' && c2 == '\\')
+ {
+ for (j = i; j < len; ++j)
+ e->value.character.string[j] = e->value.character.string[j+1];
+ len--;
+ }
+ }
+ e->value.character.length = len;
+ }
+
return MATCH_YES;
}
My understanding of io.c is not quite good, so perhaps someone who understands
that code well can have a look at a proper fix.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30278
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/30278] Inconsistencies with backslash handling
2006-12-22 15:13 [Bug fortran/30278] New: Inconsistencies with backslash handling tobi at gcc dot gnu dot org
` (3 preceding siblings ...)
2006-12-23 12:52 ` steven at gcc dot gnu dot org
@ 2006-12-23 13:12 ` tobi at gcc dot gnu dot org
2006-12-23 13:17 ` steven at gcc dot gnu dot org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: tobi at gcc dot gnu dot org @ 2006-12-23 13:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from tobi at gcc dot gnu dot org 2006-12-23 13:12 -------
NB The whole of \-ed symbols would have to be interpreted, conditionalized on
-fbackslash.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30278
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/30278] Inconsistencies with backslash handling
2006-12-22 15:13 [Bug fortran/30278] New: Inconsistencies with backslash handling tobi at gcc dot gnu dot org
` (4 preceding siblings ...)
2006-12-23 13:12 ` tobi at gcc dot gnu dot org
@ 2006-12-23 13:17 ` steven at gcc dot gnu dot org
2006-12-24 3:14 ` jvdelisle at gcc dot gnu dot org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: steven at gcc dot gnu dot org @ 2006-12-23 13:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from steven at gcc dot gnu dot org 2006-12-23 13:17 -------
Created an attachment (id=12838)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=12838&action=view)
Handle escaped characters if flag_backslash
Slightly less horrible patch...
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30278
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/30278] Inconsistencies with backslash handling
2006-12-22 15:13 [Bug fortran/30278] New: Inconsistencies with backslash handling tobi at gcc dot gnu dot org
` (5 preceding siblings ...)
2006-12-23 13:17 ` steven at gcc dot gnu dot org
@ 2006-12-24 3:14 ` jvdelisle at gcc dot gnu dot org
2007-01-27 17:14 ` kargl at gcc dot gnu dot org
2007-01-27 17:16 ` kargl at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2006-12-24 3:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from jvdelisle at gcc dot gnu dot org 2006-12-24 03:14 -------
With th patch in comment #5, NIST tests go OK. It matches g77 behavior.
I am thinking though that the default behavior should be -fno-backslash. With
-fno-backslash, gfortran matches intel behavior. My impression is that
escaping with backslashes is non-standard behavior, so we should require a
parameter to invoke it. It could also be tied in with -std=legacy.
If not this, then we should at least do -fno-backslash with -std=f95
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30278
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/30278] Inconsistencies with backslash handling
2006-12-22 15:13 [Bug fortran/30278] New: Inconsistencies with backslash handling tobi at gcc dot gnu dot org
` (6 preceding siblings ...)
2006-12-24 3:14 ` jvdelisle at gcc dot gnu dot org
@ 2007-01-27 17:14 ` kargl at gcc dot gnu dot org
2007-01-27 17:16 ` kargl at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: kargl at gcc dot gnu dot org @ 2007-01-27 17:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from kargl at gcc dot gnu dot org 2007-01-27 17:14 -------
Subject: Bug 30278
Author: kargl
Date: Sat Jan 27 17:14:06 2007
New Revision: 121234
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=121234
Log:
2007-01-26 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/30278
* gfortran.dg/backslash_3.f: New test.
2007-01-26 Steven Bosscher <stevenb.gcc@gmail.com>
Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/30278
* fortran/io.c (next_char): Deal with backslash escaped characters.
Issue warnings in non -std=gnu cases.
* fortran/primary.c (next_string_char): Issue warnings in non
Added:
branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/backslash_3.f
Modified:
branches/gcc-4_1-branch/gcc/fortran/ChangeLog
branches/gcc-4_1-branch/gcc/fortran/io.c
branches/gcc-4_1-branch/gcc/fortran/primary.c
branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30278
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/30278] Inconsistencies with backslash handling
2006-12-22 15:13 [Bug fortran/30278] New: Inconsistencies with backslash handling tobi at gcc dot gnu dot org
` (7 preceding siblings ...)
2007-01-27 17:14 ` kargl at gcc dot gnu dot org
@ 2007-01-27 17:16 ` kargl at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: kargl at gcc dot gnu dot org @ 2007-01-27 17:16 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from kargl at gcc dot gnu dot org 2007-01-27 17:16 -------
Fixed in 4.1, 4.2, and trunk.
--
kargl at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30278
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2007-01-27 17:16 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-22 15:13 [Bug fortran/30278] New: Inconsistencies with backslash handling tobi at gcc dot gnu dot org
2006-12-23 12:12 ` [Bug fortran/30278] " steven at gcc dot gnu dot org
2006-12-23 12:19 ` steven at gcc dot gnu dot org
2006-12-23 12:43 ` steven at gcc dot gnu dot org
2006-12-23 12:52 ` steven at gcc dot gnu dot org
2006-12-23 13:12 ` tobi at gcc dot gnu dot org
2006-12-23 13:17 ` steven at gcc dot gnu dot org
2006-12-24 3:14 ` jvdelisle at gcc dot gnu dot org
2007-01-27 17:14 ` kargl at gcc dot gnu dot org
2007-01-27 17:16 ` kargl 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).