erroneous warning about line truncation

View: New views
8 Messages — Rating Filter:   Alert me  

erroneous warning about line truncation

by Hans Horn-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Folks,

I get warnings about line truncation on fixed-form (f77) code when I
have inline comments starting at column 73 and beyond.

I mocked up this little piece of silly code to demonstrate:

       subroutine foo
       IMPLICIT NONE
       Integer stupid_dummy_variable1 ! stupid_dummy_variable1
       Integer stupid_dummy_variable2
! stupid_dummy_variable2
       Integer stupid_dummy_variable3
  ! stupid_dummy_variable3

       write(*,*) stupid_dummy_variable1,
      &           stupid_dummy_variable2,
      &           stupid_dummy_variable3

       end

Compiling it gives:

$ gfc -Wall -c foo.f
foo.f:5.72:

       Integer stupid_dummy_variable3
                                                                         1
Warning: Line truncated at (1)

H.


Re: erroneous warning about line truncation

by Hans Horn-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hans Horn wrote:

> Folks,
>
> I get warnings about line truncation on fixed-form (f77) code when I
> have inline comments starting at column 73 and beyond.
>
> I mocked up this little piece of silly code to demonstrate:
>
>       subroutine foo
>       IMPLICIT NONE
>       Integer stupid_dummy_variable1 ! stupid_dummy_variable1
>       Integer stupid_dummy_variable2 ! stupid_dummy_variable2
>       Integer stupid_dummy_variable3  ! stupid_dummy_variable3
>
>       write(*,*) stupid_dummy_variable1,
>      &           stupid_dummy_variable2,
>      &           stupid_dummy_variable3
>
>       end
>
> Compiling it gives:
>
> $ gfc -Wall -c foo.f
> foo.f:5.72:
>
>       Integer stupid_dummy_variable3
>                                                                         1
> Warning: Line truncated at (1)
>
> H.
>

Forgot: it's gfortran v4.5 I'm using....


Re: erroneous warning about line truncation

by Steve Kargl :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Nov 02, 2009 at 09:03:10AM -0800, Hans Horn wrote:
> Folks,
>
> I get warnings about line truncation on fixed-form (f77) code when I
> have inline comments starting at column 73 and beyond.
>

Fixed-form code is restricted to 72 columns.  From the Fortran
2003 Standard.

3.3.2      Fixed source form

In fixed source form, there are restrictions on where a statement mayr
appear within a line.  If a source line contains only default kind
characters, it shall contain exactly 72 characters; otherwise, its
maximum number of characters is processor dependent.

See the gfortran manual for options that allows you to violate this
restricton.

--
Steve

Re: erroneous warning about line truncation

by Hans Horn-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Steve Kargl wrote:

> On Mon, Nov 02, 2009 at 09:03:10AM -0800, Hans Horn wrote:
>> Folks,
>>
>> I get warnings about line truncation on fixed-form (f77) code when I
>> have inline comments starting at column 73 and beyond.
>>
>
> Fixed-form code is restricted to 72 columns.  From the Fortran
> 2003 Standard.
>
> 3.3.2      Fixed source form
>
> In fixed source form, there are restrictions on where a statement mayr
> appear within a line.  If a source line contains only default kind
> characters, it shall contain exactly 72 characters; otherwise, its
> maximum number of characters is processor dependent.
>
> See the gfortran manual for options that allows you to violate this
> restricton.
>

Steve,

line 5 in the mock code I posted emits a warning, while line 4 doesn't.
Both lines are more than 72 chars in length.

       subroutine foo
       IMPLICIT NONE
       Integer stupid_dummy_variable1 ! stupid_dummy_variable1
       Integer stupid_dummy_variable2
! stupid_dummy_variable2
       Integer stupid_dummy_variable3
  ! stupid_dummy_variable3

       write(*,*) stupid_dummy_variable1,
      &           stupid_dummy_variable2,
      &           stupid_dummy_variable3

       end

If that part of the standard applies to inline comments as well, then
I'd expect that both lines should emit a warning .

H.


Re: erroneous warning about line truncation

by Steve Kargl :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Nov 02, 2009 at 09:47:03AM -0800, Hans Horn wrote:

> Steve Kargl wrote:
> >On Mon, Nov 02, 2009 at 09:03:10AM -0800, Hans Horn wrote:
> >>Folks,
> >>
> >>I get warnings about line truncation on fixed-form (f77) code when I
> >>have inline comments starting at column 73 and beyond.
> >>
> >
> >Fixed-form code is restricted to 72 columns.  From the Fortran
> >2003 Standard.
> >
> >3.3.2      Fixed source form
> >
> >In fixed source form, there are restrictions on where a statement mayr
> >appear within a line.  If a source line contains only default kind
> >characters, it shall contain exactly 72 characters; otherwise, its
> >maximum number of characters is processor dependent.
> >
> >See the gfortran manual for options that allows you to violate this
> >restricton.
> >
>
> Steve,
>
> line 5 in the mock code I posted emits a warning, while line 4 doesn't.
> Both lines are more than 72 chars in length.
>
>       subroutine foo
>       IMPLICIT NONE
>       Integer stupid_dummy_variable1 ! stupid_dummy_variable1
>       Integer stupid_dummy_variable2
> ! stupid_dummy_variable2
>       Integer stupid_dummy_variable3
>  ! stupid_dummy_variable3

Actually, after I unwrap the two comments (email programs have a funny
habit of wrapping long lines).  Neither gives a warning.  Of course,
I simply unwrapped the lines.  You've obviously done something more
with the above example; perhaps, starting the two comments in
column 73. Let's see.

troutmask:sgk[208] nedit fh.f  (unfix to column 73)
troutmask:sgk[207] gfc4x -c -Wall fh.f
fh.f:4.72:

      Integer stupid_dummy_variable2                                    
                                                                        1
Warning: Line truncated at (1)
fh.f:5.72:

      Integer stupid_dummy_variable3                                    
                                                                        1
Warning: Line truncated at (1)

Yep, the lines of turncated.  RTFM.

troutmask:sgk[216] gfc4x -c -Wall -ffixed-line-length-none fh.f

To re-iterate, fixed-form is restricted to 72 columns.  Period.

--
Steve

Re: erroneous warning about line truncation

by Hans Horn-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Steve Kargl wrote:

> On Mon, Nov 02, 2009 at 09:47:03AM -0800, Hans Horn wrote:
>> Steve Kargl wrote:
>>> On Mon, Nov 02, 2009 at 09:03:10AM -0800, Hans Horn wrote:
>>>> Folks,
>>>>
>>>> I get warnings about line truncation on fixed-form (f77) code when I
>>>> have inline comments starting at column 73 and beyond.
>>>>
>>> Fixed-form code is restricted to 72 columns.  From the Fortran
>>> 2003 Standard.
>>>
>>> 3.3.2      Fixed source form
>>>
>>> In fixed source form, there are restrictions on where a statement mayr
>>> appear within a line.  If a source line contains only default kind
>>> characters, it shall contain exactly 72 characters; otherwise, its
>>> maximum number of characters is processor dependent.
>>>
>>> See the gfortran manual for options that allows you to violate this
>>> restricton.
>>>
>> Steve,
>>
>> line 5 in the mock code I posted emits a warning, while line 4 doesn't.
>> Both lines are more than 72 chars in length.
>>
>>       subroutine foo
>>       IMPLICIT NONE
>>       Integer stupid_dummy_variable1 ! stupid_dummy_variable1
>>       Integer stupid_dummy_variable2
>> ! stupid_dummy_variable2
>>       Integer stupid_dummy_variable3
>>  ! stupid_dummy_variable3
>
> Actually, after I unwrap the two comments (email programs have a funny
> habit of wrapping long lines).  Neither gives a warning.  Of course,
> I simply unwrapped the lines.  You've obviously done something more
> with the above example; perhaps, starting the two comments in
> column 73. Let's see.
>
> troutmask:sgk[208] nedit fh.f  (unfix to column 73)
> troutmask:sgk[207] gfc4x -c -Wall fh.f
> fh.f:4.72:
>
>       Integer stupid_dummy_variable2                                    
>                                                                         1
> Warning: Line truncated at (1)
> fh.f:5.72:
>
>       Integer stupid_dummy_variable3                                    
>                                                                         1
> Warning: Line truncated at (1)
>
> Yep, the lines of turncated.  RTFM.
>
> troutmask:sgk[216] gfc4x -c -Wall -ffixed-line-length-none fh.f
>
> To re-iterate, fixed-form is restricted to 72 columns.  Period.
>
Steve,

may be I try one more time, this time by attaching the source.
line 5 emits warning, line 4 not - both lines are longer than 72 chars
if the comments are taken into consideration. the actual statements
(decls. of stupid_dummy_variable2,3) both end at column 36.

I guess it'll come down to religious interpretation of the standard
document (which I don't have access to) whether inline comments are part
of statements or not.

H.

      subroutine foo
      IMPLICIT NONE
      Integer stupid_dummy_variable1 ! stupid_dummy_variable1
      Integer stupid_dummy_variable2                                   ! stupid_dummy_variable2
      Integer stupid_dummy_variable3                                    ! stupid_dummy_variable3

      write(*,*) stupid_dummy_variable1,
     &           stupid_dummy_variable2,
     &           stupid_dummy_variable3

      end

Re: erroneous warning about line truncation

by Daniel Franke-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Monday 02 November 2009 19:59:29 Hans Horn wrote:

To add my 2ct ...

> may be I try one more time, this time by attaching the source.
> line 5 emits warning, line 4 not - both lines are longer than 72 chars
> if the comments are taken into consideration. the actual statements
> (decls. of stupid_dummy_variable2,3) both end at column 36.

Line 4 indicates within the valid range that the remainder is a comment while
line 5 simply trails over the edge and there still _might_ be something
significant there. The warning is probably emitted while going through the
characters of the line without trimming comments first, I didn't check the
details.

Cheers

        Daniel

Re: erroneous warning about line truncation

by Jerry DeLisle :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 11/02/2009 10:59 AM, Hans Horn wrote:

> Steve Kargl wrote:
>> On Mon, Nov 02, 2009 at 09:47:03AM -0800, Hans Horn wrote:
>>> Steve Kargl wrote:
>>>> On Mon, Nov 02, 2009 at 09:03:10AM -0800, Hans Horn wrote:
>>>>> Folks,
>>>>>
>>>>> I get warnings about line truncation on fixed-form (f77) code when
>>>>> I have inline comments starting at column 73 and beyond.
>>>>>
>>>> Fixed-form code is restricted to 72 columns. From the Fortran
>>>> 2003 Standard.
>>>>
>>>> 3.3.2 Fixed source form
>>>>
>>>> In fixed source form, there are restrictions on where a statement mayr
>>>> appear within a line. If a source line contains only default kind
>>>> characters, it shall contain exactly 72 characters; otherwise, its
>>>> maximum number of characters is processor dependent.
>>>>
>>>> See the gfortran manual for options that allows you to violate this
>>>> restricton.
>>>>
>>> Steve,
>>>
>>> line 5 in the mock code I posted emits a warning, while line 4 doesn't.
>>> Both lines are more than 72 chars in length.
>>>
>>> subroutine foo
>>> IMPLICIT NONE
>>> Integer stupid_dummy_variable1 ! stupid_dummy_variable1
>>> Integer stupid_dummy_variable2 ! stupid_dummy_variable2
>>> Integer stupid_dummy_variable3 ! stupid_dummy_variable3
>>
>> Actually, after I unwrap the two comments (email programs have a funny
>> habit of wrapping long lines). Neither gives a warning. Of course,
>> I simply unwrapped the lines. You've obviously done something more
>> with the above example; perhaps, starting the two comments in
>> column 73. Let's see.
>>
>> troutmask:sgk[208] nedit fh.f (unfix to column 73)
>> troutmask:sgk[207] gfc4x -c -Wall fh.f
>> fh.f:4.72:
>>
>> Integer stupid_dummy_variable2 1
>> Warning: Line truncated at (1)
>> fh.f:5.72:
>>
>> Integer stupid_dummy_variable3 1
>> Warning: Line truncated at (1)
>>
>> Yep, the lines of turncated. RTFM.
>>
>> troutmask:sgk[216] gfc4x -c -Wall -ffixed-line-length-none fh.f
>>
>> To re-iterate, fixed-form is restricted to 72 columns. Period.
>>
>
> Steve,
>
> may be I try one more time, this time by attaching the source.
> line 5 emits warning, line 4 not - both lines are longer than 72 chars
> if the comments are taken into consideration. the actual statements
> (decls. of stupid_dummy_variable2,3) both end at column 36.
>
> I guess it'll come down to religious interpretation of the standard
> document (which I don't have access to) whether inline comments are part
> of statements or not.
>
> H.
Actually, this really is a bunch of nit picking.  Both lines are truncated.  In
the one case, it is truncated before it is determined to be a comment line.  We
choose to ignore truncation of comment lines but will warn if you ask for it
with -Wall.  On line 5, gfortran never sees the comment marker '!', it just
knows something was there and was truncated.

The warning is provided as a courtesy, not has a big flag that something must be
wrong, end of the world and all that!

Want to have some fun?  Try this:

$ gfc -c -Wall -ffixed-line-length-74 foo.f
$ gfc -c -Wall -ffixed-line-length-71 foo.f
foo.f:4.71:

       Integer stupid_dummy_variable2
                                                                        1
Warning: Line truncated at (1)
foo.f:5.71:

       Integer stupid_dummy_variable3
                                                                        1
Warning: Line truncated at (1)

Wow, I can make the warning go away or I can make it warn on both lines!

Amazing isn't it?

Jerry