Previous mail
Next mail
Unformatted/full headers
Overview 10 days
Subject
Date
Thread
Author
From: Tom Schneider
Subject: Upper/lower case in identifiers
Date: 10 Sep 2004, 18:42:00
program capbug(output);
(* capbug: capitalization bug in gpc compiler
Dr. Thomas D. Schneider
National Cancer Institute
Laboratory of Experimental and Computational Biology
Molecular Information Theory Group
Frederick, Maryland 21702-1201
toms@ncifcrf.gov
permanent email: toms@alum.mit.edu (use only if first address fails)
http://www.lecb.ncifcrf.gov/~toms/
*)
const
(* begin module version *)
version = 1.00; (* of capbug.p 2004 Sep 10
2004 Sep 10, 1.00: origin
*)
(* end module version *)
(* begin module describe.capbug *)
(*
name
capbug: capitalization bug in gpc compiler
synopsis
capbug(output: out)
files
output: messages to the user
description
Demonstrate capitals bug in GPC. The name of a local procedure is
objected to by GPC if there is a global by the same name but
different capitalization.
In theory the compiler should keep track of what is local and what
is global anyway, so it should be able to avoid this.
It is a problem because if one imports procedures from another
program, they are not being treated as pure 'black boxes'.
Instead, local variable names are being compared to the global
variable names.
In otherwords, the scope rule of Pascal is being violated
when these warnings are generated.
This problem is not fixed by adding the flag:
-Widentifier-case-local
Warn about an identifier written with varying case within one
program/module/unit.
examples
gpc 20040516, based on gcc-3.3.3
for this program itself gives:
capbug.p:113: warning: capitalisation of `x' doesn't match
capbug.p:111: warning: previous capitalisation `X'
capbug.p:113: warning: capitalisation of `y' doesn't match
capbug.p:111: warning: previous capitalisation `Y'
capbug.p: In procedure `themain':
capbug.p:138: warning: capitalisation of `X' doesn't match
capbug.p:113: warning: previous capitalisation `x'
capbug.p:139: warning: capitalisation of `Y' doesn't match
capbug.p:113: warning: previous capitalisation `y'
The result is:
capbug 1.00
outside: x = 1
outside: y = 2
inside: x = 3
inside: y = 4
themain: X = 5
themain: Y = 6
which demonstrates that the scope rules are being followed when the
progrm runs, because X and Y are set before the calls to routines
outside and inside, but they are not affected by those calls. That
is, the outside and inside routines have local variables.
documentation
see also
{Manual on GPC that gives the -Widentifier-case-local flag:}
http://www.gnu-pascal.de/gpc/GPC-Command-Line-Options.html
{Discussion on the topic, "Upper/lower case in identifiers":}
http://www.gnu-pascal.de/crystal/gpc/en/raw-mail7665.html
author
Thomas Dana Schneider
bugs
technical notes
*)
(* end module describe.capbug *)
var
X, Y: integer; (* global X and Y *)
procedure outside(x, y: integer);
(* an outside procedure *)
begin
x := 1;
y := 2;
writeln(output,'outside: x = ',x:1);
writeln(output,'outside: y = ',y:1);
end;
(* begin module capbug.themain *)
procedure themain;
(* the main procedure of the program *)
procedure inside(x, y: integer);
(* an inside procedure *)
begin
x := 3;
y := 4;
writeln(output,'inside: x = ',x:1);
writeln(output,'inside: y = ',y:1);
end;
begin
writeln(output,'capbug ',version:4:2);
X := 5;
Y := 6;
outside(X, Y);
inside(X, Y);
writeln(output,'themain: X = ',X:1);
writeln(output,'themain: Y = ',Y:1);
end;
(* end module capbug.themain *)
begin
themain;
end.
Previous mail
Next mail
Unformatted/full headers
Overview 10 days
Subject
Date
Thread
Author
| Author | Subject | Date |
|---|---|---|
| Waldek Hebisch | Upper/lower case in identifiers | 11 Sep 2004, 02:51:31 |
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).