public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/39229] New: fixed-form: silent line truncation in procedure calls
@ 2009-02-18 9:46 dfranke at gcc dot gnu dot org
2009-02-18 10:20 ` [Bug fortran/39229] No warning of truncated lines if a continuation line follows burnus at gcc dot gnu dot org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2009-02-18 9:46 UTC (permalink / raw)
To: gcc-bugs
If 'warn' after PRINT is removed, the snippet is accepted as is, without
further warning. I'm not sure if this kind of thing is legal to begin with, but
I'd at least expect a warning for both truncated lines.
$> cat trunc.f
PRINT *, MIN(1 nowarn
&, 2) ! warn
END
$> gfortran-svn -ffixed-form -Wall -Wextra trunc.f
trunc.f:2.72:
&, 2)
1
Warning: Line truncated at (1)
$> gfortran-svn -v
gcc version 4.4.0 20090217 (experimental) (GCC)
--
Summary: fixed-form: silent line truncation in procedure calls
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dfranke at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39229
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/39229] No warning of truncated lines if a continuation line follows
2009-02-18 9:46 [Bug fortran/39229] New: fixed-form: silent line truncation in procedure calls dfranke at gcc dot gnu dot org
@ 2009-02-18 10:20 ` burnus at gcc dot gnu dot org
2009-02-18 16:41 ` burnus at gcc dot gnu dot org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-02-18 10:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from burnus at gcc dot gnu dot org 2009-02-18 10:20 -------
I think that also happens if one does not have a procedure call but simply have
a succeeding continuation line, e.g.:
print *, min(1,2) [...] some long line
& , 2
And it seems to happen also with free-form code which has warning enabled by
default.
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu dot
| |org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2009-02-18 10:20:31
date| |
Summary|fixed-form: silent line |No warning of truncated
|truncation in procedure |lines if a continuation line
|calls |follows
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39229
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/39229] No warning of truncated lines if a continuation line follows
2009-02-18 9:46 [Bug fortran/39229] New: fixed-form: silent line truncation in procedure calls dfranke at gcc dot gnu dot org
2009-02-18 10:20 ` [Bug fortran/39229] No warning of truncated lines if a continuation line follows burnus at gcc dot gnu dot org
@ 2009-02-18 16:41 ` burnus at gcc dot gnu dot org
2009-02-23 19:38 ` dfranke at gcc dot gnu dot org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-02-18 16:41 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from burnus at gcc dot gnu dot org 2009-02-18 16:41 -------
> I'm not sure if this kind of thing is legal to begin with
Well, the Fortran standard only has:
Free form: "If a line consists entirely of characters of default kind (4.4.4),
it may contain at most 132 characters. If a line contains any character that is
not of default kind, the maximum number of characters allowed on the line is
processor dependent." [3.3.1]
Fixed form: "If a source line contains only default kind characters, it shall
contain exactly 72 characters; otherwise, its maximum number of characters is
processor dependent."
Thus a conforming program may not have more than 72/132 characters in a line
(incl. comments) and this is no issue. The standard does not write anything
about what the compiler has to do.
Common is that 73+ characters are ignored in fixed form and thus several people
used it to put comments there. Additionally, everyone assumes that longer lines
are OK as long as long as there is a "!" before 72/132. (-> all compilers I
know do so).
As free form indicates non-legacy code and as F90 has "!" comments, the
truncation trick wont work. Some compilers truncates, some give an error, some
a warning (and stop - or continue reading the line) and some simply read on.
gfortran does: Fixed form: Truncating + optional warning
Free form: Truncating + default-on warning
optionally: Accept longer lines ("n" characters or "infinity")
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39229
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/39229] No warning of truncated lines if a continuation line follows
2009-02-18 9:46 [Bug fortran/39229] New: fixed-form: silent line truncation in procedure calls dfranke at gcc dot gnu dot org
2009-02-18 10:20 ` [Bug fortran/39229] No warning of truncated lines if a continuation line follows burnus at gcc dot gnu dot org
2009-02-18 16:41 ` burnus at gcc dot gnu dot org
@ 2009-02-23 19:38 ` dfranke at gcc dot gnu dot org
2009-03-08 18:05 ` jvdelisle at gcc dot gnu dot org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2009-02-23 19:38 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from dfranke at gcc dot gnu dot org 2009-02-23 19:38 -------
parse.c (next_statement):
816 if (gfc_at_eol ())
817 {
818 if ((gfc_option.warn_line_truncation || gfc_current_form ==
FORM_FREE)
819 && gfc_current_locus.lb
820 && gfc_current_locus.lb->truncated)
821 gfc_warning_now ("Line truncated at %C");
822
823 gfc_advance_line ();
824 }
scanner.c:
gfc_at_eol (void)
{
if (gfc_at_eof ())
return 1;
return (*gfc_current_locus.nextc == '\0');
}
in gdb:
Breakpoint 1, next_statement () at
/home/daniel/svn/gcc-whole-file/gcc/fortran/parse.c:816
816 if (gfc_at_eol ())
(gdb) print *gfc_current_locus->lb
$22 = {location = 3, file = 0xa8a4930, next = 0xa8bb5f8, truncated = 1,
dbg_emitted = 0 '\0', line = {32}}
(gdb) print *gfc_current_locus->nextc
$23 = 32
(gdb) cont
Continuing.
Breakpoint 1, next_statement () at
/home/daniel/svn/gcc-whole-file/gcc/fortran/parse.c:816
816 if (gfc_at_eol ())
(gdb) print *gfc_current_locus->lb
$24 = {location = 131, file = 0xa8a4930, next = 0xa8bb738, truncated = 0,
dbg_emitted = 1 '\001', line = {32}}
(gdb) print *gfc_current_locus->nextc
$25 = 0
For the continued line gfc_at_eol() returns false and thus its truncated-flag
is silently lost.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39229
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/39229] No warning of truncated lines if a continuation line follows
2009-02-18 9:46 [Bug fortran/39229] New: fixed-form: silent line truncation in procedure calls dfranke at gcc dot gnu dot org
` (2 preceding siblings ...)
2009-02-23 19:38 ` dfranke at gcc dot gnu dot org
@ 2009-03-08 18:05 ` jvdelisle at gcc dot gnu dot org
2009-07-25 16:46 ` jvdelisle at gcc dot gnu dot org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2009-03-08 18:05 UTC (permalink / raw)
To: gcc-bugs
--
jvdelisle at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |jvdelisle at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Last reconfirmed|2009-02-18 10:20:31 |2009-03-08 18:05:25
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39229
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/39229] No warning of truncated lines if a continuation line follows
2009-02-18 9:46 [Bug fortran/39229] New: fixed-form: silent line truncation in procedure calls dfranke at gcc dot gnu dot org
` (3 preceding siblings ...)
2009-03-08 18:05 ` jvdelisle at gcc dot gnu dot org
@ 2009-07-25 16:46 ` jvdelisle at gcc dot gnu dot org
2009-07-25 17:10 ` burnus at gcc dot gnu dot org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2009-07-25 16:46 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from jvdelisle at gcc dot gnu dot org 2009-07-25 16:46 -------
There are two things going on here. First, because of the continuation, the
scanner actually combines the two lines into one line. Secondly, we have code
that deliberately clears the truncation flag because it was considered a
nuisance to warn on anything after a comment.
/* Avoid truncation warnings for comment ending lines. */
gfc_current_locus.lb->truncated = 0;
I am inclined to leave this as is because it is a common practice to use
positions 73 thru 80 for indexing in legacy fixed form code. (Remember those
punch cards!)
Changing to won't fix. If someone feels strongly about this otherwise, just
let me know. It is not difficult to change.
--
jvdelisle at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |WONTFIX
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39229
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/39229] No warning of truncated lines if a continuation line follows
2009-02-18 9:46 [Bug fortran/39229] New: fixed-form: silent line truncation in procedure calls dfranke at gcc dot gnu dot org
` (4 preceding siblings ...)
2009-07-25 16:46 ` jvdelisle at gcc dot gnu dot org
@ 2009-07-25 17:10 ` burnus at gcc dot gnu dot org
2009-09-01 3:02 ` jvdelisle at gcc dot gnu dot org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-07-25 17:10 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from burnus at gcc dot gnu dot org 2009-07-25 17:09 -------
(In reply to comment #4)
> I am inclined to leave this as is because it is a common practice to use
> positions 73 thru 80 for indexing in legacy fixed form code. (Remember those
> punch cards!)
Yes - and that's the reason why there is no warning by default. But it happens
very easily that one adds a space somewhere and all of a sudden the result
changes. How many lines does the following program print?
For that reason, gfortran offers an option to diagnose this. If one uses those
columns for comments, one does not need to enable the warning (off by default
for fixed-form code).
! Expected: No warning by default (as column 73+ is often used for
! comments in fixed-form source code.
! However, with -Wline-truncation there shall be a warning.
implicit none
call foo([11, 22, 33, 44, 55, 66, 770, 9900, 1100, 1100, 120], 12
& , 'Hello')
contains
subroutine foo(a,n,s)
integer :: a(*), n, i
character(len=*) :: s
do i = 1, n
print *, s, a(i)
end do
end subroutine foo
end
! Answer: One line, the "12" gets truncated to "1". Such problems can easily
happens if one corrects e.g. a "99" to "100" - and the previous editor used all
space and put the comma in the next line.
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|WONTFIX |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39229
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/39229] No warning of truncated lines if a continuation line follows
2009-02-18 9:46 [Bug fortran/39229] New: fixed-form: silent line truncation in procedure calls dfranke at gcc dot gnu dot org
` (5 preceding siblings ...)
2009-07-25 17:10 ` burnus at gcc dot gnu dot org
@ 2009-09-01 3:02 ` jvdelisle at gcc dot gnu dot org
2009-09-02 1:04 ` jvdelisle at gcc dot gnu dot org
2009-09-02 1:19 ` jvdelisle at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2009-09-01 3:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from jvdelisle at gcc dot gnu dot org 2009-09-01 03:02 -------
Subject: Bug 39229
Author: jvdelisle
Date: Tue Sep 1 03:02:07 2009
New Revision: 151258
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=151258
Log:
2009-08-31 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/39229
* scanner.c (next_char): Fix typo in comment.
(gfc_get_char_literal): Warn if truncate flag is set for both fixed and
free form source, adjusting error locus as needed.
* parse.c (next_fixed): Clear the truncate flag.
(next_statement): Remove truncate warning.
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/parse.c
trunk/gcc/fortran/scanner.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39229
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/39229] No warning of truncated lines if a continuation line follows
2009-02-18 9:46 [Bug fortran/39229] New: fixed-form: silent line truncation in procedure calls dfranke at gcc dot gnu dot org
` (6 preceding siblings ...)
2009-09-01 3:02 ` jvdelisle at gcc dot gnu dot org
@ 2009-09-02 1:04 ` jvdelisle at gcc dot gnu dot org
2009-09-02 1:19 ` jvdelisle at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2009-09-02 1:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from jvdelisle at gcc dot gnu dot org 2009-09-02 01:03 -------
Subject: Bug 39229
Author: jvdelisle
Date: Wed Sep 2 01:03:34 2009
New Revision: 151309
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=151309
Log:
2009-09-01 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/39229
* gfortran.dg/line_length_3.f: New test.
* gfortran.dg/line_length_4.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/line_length_3.f
trunk/gcc/testsuite/gfortran.dg/line_length_4.f90
Modified:
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39229
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/39229] No warning of truncated lines if a continuation line follows
2009-02-18 9:46 [Bug fortran/39229] New: fixed-form: silent line truncation in procedure calls dfranke at gcc dot gnu dot org
` (7 preceding siblings ...)
2009-09-02 1:04 ` jvdelisle at gcc dot gnu dot org
@ 2009-09-02 1:19 ` jvdelisle at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2009-09-02 1:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from jvdelisle at gcc dot gnu dot org 2009-09-02 01:19 -------
Closing.
--
jvdelisle at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39229
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2009-09-02 1:19 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-18 9:46 [Bug fortran/39229] New: fixed-form: silent line truncation in procedure calls dfranke at gcc dot gnu dot org
2009-02-18 10:20 ` [Bug fortran/39229] No warning of truncated lines if a continuation line follows burnus at gcc dot gnu dot org
2009-02-18 16:41 ` burnus at gcc dot gnu dot org
2009-02-23 19:38 ` dfranke at gcc dot gnu dot org
2009-03-08 18:05 ` jvdelisle at gcc dot gnu dot org
2009-07-25 16:46 ` jvdelisle at gcc dot gnu dot org
2009-07-25 17:10 ` burnus at gcc dot gnu dot org
2009-09-01 3:02 ` jvdelisle at gcc dot gnu dot org
2009-09-02 1:04 ` jvdelisle at gcc dot gnu dot org
2009-09-02 1:19 ` jvdelisle 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).