GNU Pascal Homepage - gpc - gpc-announce - gpc-de - gpc-doc
Diese Seite auf deutsch

Mail #9097

Back to main page of archive

Previous mail   Next mail   Unformatted/full headers
Overview  10 days   Subject   Date   Thread   Author  

From: Gale Paeper
Subject: Bug report/feature request: overly
Date: 27 Jul 2003, 11:28:15

Frank Heckenbach wrote:
> 
> Gale Paeper wrote:
> 
> > Joseph Oswald wrote:
> > >
> > > The attached program demonstrates an issue with Gnu Pascal, version
> > > 20030507. The program cannot be compiled because of a non-existent "threat"
> > > on the global loop variable used in a subroutine. The main program has a
> > > loop which uses the variable, but calls no subroutines within the loop, and
> > > therefore is not vulnerable to any threat from use of that variable by other
> > > subroutines.
> > >
> > > Attempting to compile this program results in the message
> > >
> > > gpc -o forwarning forwarning.pas
> > > forwarning.pas: In main program:
> > > forwarning.pas:13: error: `for' loop counter is threatened in a subroutine
> >
> > The program contains an error involving a for loop and when fixed GPC
> > compiles the program with no errors.  The above error message, though,
> > is pretty misleading as to real error in the program.
> >
> > Both Pascal standards specify the following requirement for for-statements:
> >
> > "The control-variable shall be an entire-variable whose identifier is
> > declared in a variable-declaration- part of the block closest-containing
> > the for-statement."
> 
> That's another error, at least in the test program, which GPC
> detects with `--classic-pascal' or `--extended-pascal'.

Since my previous posting, I dug into the compiler source code and saw
where GPC supports a Borland extension which relaxes the requirement.  
 
> However, AFAICS, also the error message above is correct since it's
> not necessary to call the routine for the error to appear:
> 
> : 6.9.3.9 For–statements
> :
> : 6.9.3.9.1 General
> :
> : Neither
> : a for–statement nor any procedure–and– function–declaration–part of the
> : block that closest–contains a for–statement shall contain a statement
> : threatening (see 6.9.4) a variable–access denoting the variable denoted by
> : the control–variable of the for–statement.
> 
> In the test program, if in useloopvar you replace the loop with a
> simple assignment to loopvar, you have this error without the first
> one.

After seeing the Borland extension support, I had though of that
variation but didn't get around to testing it.

This has helped clarify my understanding of control–variable threat
requirements.  For some reason or other, I've never picked up the full
implications of the "any procedure–and–function–declaration–part" part
of the requirement.  For-statement threat requirements is one area a lot
of compilers don't even attempt to enforce.  So one ends up adopting
coding practices which avoids the ills the threat requirements are
designed to preclude anyway.
 
[snip]
> 
> I tried to compile Web and TeX and noticed a few more problems,
> though apparently all quite minor:
> 
> - Compiler directives `{$C-,A+,D-}'
> 
> - `WriteLn' applied to `packed file of Char' rather than `Text'
> 
> - `others:' instead of `otherwise'
> 
> - `Break (FileVar)' (perhaps the same as `Page'?)
> 
> - 3rd parameter to `Reset' and `Rewrite'
> 
> - hard-coded 'TTY:' for terminal (VMS specific?; Unix has
>   '/dev/tty', Dos 'con')
> 
> - `erstat (FileVar)' (perhaps the same as BP's `IOResult' with
>   `{$I-}')
> 
> - `breakin (FileVar)' (input flushing?)
> 
> - a lot of warnings which all seem to be harmless, but point to
>   unniceties in the code
> 
> Time for `--dec-pascal' ...?

Perhaps not.  With some 'net seaching, I found a location with a set of
"master files personally by Donald E. Knuth" at
<ftp://ctan.tug.org/tex-archive/systems/knuth/>.  In that file set,
there are change files with comments like "Change file for GNU Pascal
and Linux".  Never having worked with Web and TeX code before, I don't
know how much help those files will be in fixing the problems but it
does seem to have a some promising potential.

Gale Paeper
gpaeper@empirenet.com

Previous mail   Next mail   Unformatted/full headers
Overview  10 days   Subject   Date   Thread   Author  


Replies

Author Subject Date
Frank Heckenbach overly aggressive warning message 27 Jul 2003, 21:07:08

In reply to

Author Subject Date
Joseph Oswald Bug report/feature request: overly aggressive warning on use of for-loop variable 26 Jul 2003, 23:39:55
Gale Paeper Bug report/feature request: overly aggressive warning on use 26 Jul 2003, 22:39:08
Frank Heckenbach Bug report/feature request: overly 27 Jul 2003, 15:33:00

Back to main page of archive


Note: This page contains information that does not originate from the owner of this web site, but from the authors of the mails archived. The owner of this web site is not responsible for the content of such information. Any use of that infomation requires the consent of the respective author.

Where WWW addresses (URLs) in the mails archived are marked as hyperlinks, this is only for the comfort of the reader. The content of the web pages linked to like this does not necessarily reflect the opinion of the owner of this web site or of the authors of the mails archived. The owner of this web site is not responsible for the content of such web pages. Those pages are explicitly not to be considered as part of the content of this page, but merely as references.


This page was created by Crystal 0.999 (Linux 2.4.27/i686).