@node GPC bugs
@chapter Known bugs and inconveniences; how to report bugs
@cindex GPC bugs
@cindex bugs in GPC

@c Last modification by Juki <jtv@@hut.fi>:
@c   Sat Mar 25 21:13:27 1995
@c Last modification by Peter <peter@gerwinski.de>: 
@c   Fri 7 Feb 1997 27:45 MET

The GNU Pascal Compiler (GPC) does not yet implement the whole ISO 10206
Extended Pascal standard, not even the whole ISO 7185 Pascal standard.
It is only partially compatible to Borland Pascal and implements only
some isolated features from the PXSC standard.  Furthermore, there are
some known bugs which will take a long time to be fixed.  (Any help
welcome!)  Please take this into account when you consider using GPC
for any purpose.

If you encounter a bug with GPC, please check whether it is one of the
known bugs.  If not, report it to the GNU Pascal mailing list
@code{gpc@@hut.fi}.  (But always report it if you solve the problem! ;-)

@c See the file @samp{version.c} to find out the version number of this GPC
@c (or run @code{gpc -v})
@c
@c The GPC version number is documented somewhere else in this
@c documentation. -- PG, 22. Sept. 1996


@section General bugs

@itemize @bullet

@item
High optimization levels do not work properly on the Alpha.  Some
conformance tests @emph{fail} when compiled with @samp{-O6} flag, which
means that the compiler generates invalid code. Don't use this flag in
the Alpha before the problem gets fixed.  It might have something to do
with automatic inlining, but I have not yet looked at this. @samp{-O}
flag should be ok.  (Also take care when using explicit inline
functions.)

@item
Run time errors are not checked in most cases.

@item
For some reason the Pascal main program does not get lineno stabs, so it
is hard to debug it with @samp{gdb} @dots{}

@c @item
@c Modules and Units export everything, not just the stuff in the export
@c interfaces.  However, the unexported variables and functions are
@c invisible to modules @emph{in other files}.
@c
@c @strong{Workaround:}
@c Put each Module or Unit in its own source file and compile it
@c separately.
@c
@c Fixed.  PG, Feb 1997

@c @item
@c The @code{GPI} mechanism sometimes fails to transport some (few)
@c data structures.
@c 
@c @strong{Workaround:}
@c Include the Unit or Module into the main program's source:
@c @smallexample
@c   (*$I MyModule *)
@c 
@c   Program MyProg;
@c 
@c   uses
@c     MyModule;
@c 
@c   ...
@c @end smallexample
@c
@c Fixed.  For most cases at least.  Since the workaround does not work
@c any more, don't confuse the users.  PG, Jul 1997

@c @item
@c When @code{gpc} is invoked for linking only, it crashes on some
@c systems.
@c 
@c @strong{Workaround:} Use @code{gcc} instead of @code{gpc} for
@c linking:
@c @smallexample
@c   gpc -c hello.pas
@c   gcc -o hello hello.o -lm -lgpc
@c @end smallexample
@c
@c Fixed by Jan-Jaap, somewhere in gpc-1.2(2.7.2:-). - PG, 22 Feb 1997

@c @item
@c Temporary @code{.gpc} files are not removed after compilation.
@c
@c Fixed. - PG, 18 Oct 1996

@c @item
@c The inline set operations have some problems with operations on two sets
@c if the sets do not contain equally many segments.
@c 
@c Fixed. - PG, 6 Feb 1997

@item
The set code generated in the Alpha causes runtime errors
in the generated code.

@item
There are some bugs with mathematical functions.  GPC fails, for
example, the ``Paranoia'' test.

@c @item
@c The main program name is not capitalized.  It may clash with libc
@c identifiers which may be important but invisible for the program, e.g.@:
@c @samp{log}.
@c
@c Fixed. - PG, 19 Oct 1996

@end itemize


@section Standard Pascal

@itemize @bullet

@c Functions returning string schema types do not work
@c (they are called about three times where they should be called
@c once)
@c
@c Eliminated. - PG, July/Aug. 1996

@item
Type checking is mostly what C does, not what Pascal requires, so GPC
does not yet implement a strongly typed language.  Although correct
programs compile, incorrect ones compile also.  Please send us such
incorrect programs, so we can fix it!

@c No GPC texinfo file exists yet. See GPC.GUIDE instead.
@c ;-) - PG, 4./5. Aug. 1996

@c @item
@c Conformant arrays don't yet work (in general).  Until they do, GPC is a
@c Level-0 Standard Pascal compiler.  
@c
@c They should work now.  PG, Feb 1997

@end itemize


@section Extended Pascal

@itemize @bullet

@c @item
@c Schema types are not yet implemented; only String schemas work.
@c
@c Fixed. :-)  PG, Jul 1997

@c @item
@c String schemas as formal value parameters do not work.
@c 
@c @strong{Workaround:}
@c Pass string types with specified capacity instead, i.e. use
@c @smallexample
@c   Type
@c     WrkString = String ( 80 );
@c 
@c   Procedure Foo ( S: WrkString );
@c @end smallexample
@c instead of
@c @smallexample
@c   Procedure Foo ( S: String );
@c @end smallexample
@c
@c Fixed.  This only concerned GPI files. - PG, 7 Feb 1997

@item
Initialized structured variables are not yet implemented.

@c Initialized Strings work. - PG, 22 Feb 1997

@item
Illegal substrings let crash the program rather than triggering a
runtime error:
@smallexample
  str:='1234567890';
  i:=8; j:=13;
  str:=str[i..j];
@end smallexample
This is one case where runtime errors should be caught, but are not.

@c @item
@c The @samp{Index} function does not work when the pattern is a char:
@c @smallexample
@c   Var 
@c      C: Char;
@c     S: String ( 80 );
@c     i: Integer;
@c
@c   ...
@c
@c  i:= Index ( s, c );  (* "i" always zero *)
@c @end smallexample
@c It works with @samp{Var C: String ( 1 );}
@c
@c Fixed. - PG, 22 Feb 1997

@end itemize


@section Borland Pascal

See also: @ref{Borland Pascal}QuickStart Guide for Borland Pascal users.

@itemize @bullet

@item
Strings are implemented in a completely different way.  They are
not limited to 255 characters with the length being in position
zero, but they are ``Schema types'' which is something more 
complicated.

@item
Most of Borland Pascal's System Unit is not implemented, e.g.@:
@samp{move}, @samp{FillChar}, @samp{BlockRead}, @samp{BlockWrite},
@samp{Assign}, String-related functions, @dots{}

@c @samp{Byte}, @samp{Pointer}, @samp{LongInt} work. - PG, 22 Feb 1997

@strong{Workaround:}
Some of the missing procedures and functions are implemented in a
separate compatibility Unit.  Check the @code{contrib} subdirectory of
your GPC distribution.

@c @item
@c Initialized structured variables do not yet work in all cases.
@c 
@c Fixed.  PG, Jun 1997

@c Initialized Strings are implemented now. - PG, 22 Feb 1997

@c @item
@c @samp{Case} has no @samp{else}, but @samp{otherwise}.
@c
@c Added "else".  PG, 27 Oct 1996

@c @item
@c Chars like @samp{^M} do not work.  Use @samp{#13} or @samp{chr ( 13 )}
@c instead.
@c
@c Fixed.  PG, May 1997

@c Added "#13".  PG, 15 Feb 1997

@c @item
@c Untyped parameters are @samp{Procedure foo ( Var Bar: Void );}, not
@c (yet) @samp{Procedure foo ( Var Bar );}.  When using them, GPC gives
@c a warning; code works.
@c
@c Fixed.  PG, 27 Oct 1996

@item
The inline assember does not understand Borland syntax.

@item
There is no @samp{private} directive for Objects yet.

@c @item
@c There are no ``Procedural types'' but @emph{pointers} to procedures
@c instead.
@c 
@c Fixed.  PG, May 1997

@item
There is no @samp{Inline} in Borland sense.

@end itemize


@section GNU Extensions

@itemize @bullet

@item
The Run Time System (RTS) does not know about modified types such
as @samp{__byte__} or @samp{__unsigned__ Integer}s or @samp{__long__
Real}s.  Especially, you cannot @samp{writeln} such variables.

@cindex foo
@strong{Workaround:} Cast them to their basis type before 
@samp{writeln}, e.g.@:
@smallexample
  Type
    Extended = __long__ Real;

  Var
    foo: Extended;

  [...]

  writeln ( Real ( foo ) );
@end smallexample

@end itemize


@section Inconveniences

@itemize @bullet

@c @item
@c @samp{New} and @samp{Dispose} optional tag field arguments are ignored
@c (warning given, code works).
@c
@c Fixed.  PG, Jul 1997

@item
The GNU debugger, @samp{gdb}, does not yet understand Pascal sets,
files or subranges.  Now @samp{gdb} allows you to debug these things,
even though it does not yet understand some stabs.

@c @item
@c @samp{Packed} does not pack.  (Implementation dependent, warning
@c given, code works.)  This means that the smallest unit is a byte, not
@c a bit; a @samp{packed array [ 1..8 ] of Boolean} has 8 bytes, not 1.
@c (One well-known vendors says that his compiler does ``always'' pack
@c when it behaves like this.  We don't.)
@c
@c Fixed.  PG, May 1997

@item
Files of integer subranges that would fit in a byte do not; instead they
are handled as files of integer.  This is especially annoying with
@samp{file of 0..255}.

@end itemize


@section Notes for debugging

@itemize @bullet

@item
Forward referencing pointers generate @samp{dbx} style debugging symbols
by outputting the @samp{.stabs} as an unknown pointer and later it just
outputs the same @samp{.stabs} again, but this time it also tells what
type the pointer points to.  This seems to work for @samp{gdb}. As of
this writing I have not checked what happens with @samp{sdb} type
debugging info.  It might be that the pointer is left to be a
@code{(void *)} pointer, so you have to cast it in order to output the
object the pointer points to.

Also, we have not tried any other debugger than @samp{gdb}.  If you do,
please let us know what happens.

I think that GDB does not yet support the kind of @samp{.stabs}
that should be used to do this correctly:

@smallexample
  .stabs ":t@var{anumber}=@var{bnumber}", @var{whatever}
@end smallexample

where @var{anumber} is the unknown pointer type referenced earlier, and
the @var{bnumber} is the type which @var{anumber} actually is.  This
construct is not required in C.

@item
When debugging, please note that the Initial Letter In Each Identifier
Is In Upper Case And The Rest Are In Lower Case.  If you wish to call
C-routines declare them with the ``C'' directive, as follows:

@smallexample
Procedure FooBAR(i:integer);c;
@end smallexample

This makes the external name to be @samp{_foobar}
(replace @code{_} with you machine prefix).

@smallexample
Procedure FooBAR(i:Integer); External;
@end smallexample

Uses external name @code{_Foobar}.

@smallexample
Procedure FooBAR(i:Integer); AsmName 'FooBAR';
@end smallexample

Uses external name @code{_FooBAR}.

It is done like this to reduce name clashes	
with @samp{libc.a} and other possible libraries.

@item
All visible GPC runtime system library routines are
named @code{_p_@dots{}}.

@item
@cindex foo
The main program name is preceeded by @code{program_}.
For example, @code{Program FOO} yields the external name
@code{program_Foo} for the main program.  This is done
because ISO Standard wants to have the program name in a
separate name space.

@end itemize
