Go to the first, previous, next, last section, table of contents.

# Known bugs and inconveniences; how to report bugs

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 lots of 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 `gpc@hut.fi`. (But always report it if you solve the problem! ;-)

## General bugs

- High optimization levels do not work properly on the Alpha. Some conformance tests fail when compiled with ``-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. ``-O'` flag should be ok. (Also take care when using explicit inline functions.)
- Run time errors are not checked.
- For some reason the pascal main program does not get lineno stabs, so it is hard to debug it with ``gdb'` ...
- Modules and Units export everything, not just the stuff in the export interfaces. However, the unexported variables and functions are invisible to modules in other files. Workaround: Put each Module or Unit in its own source file and compile it separately.
- The `GPI` mechanism crashes when compiling some Modules, for example the `System` module by Berend de Boer. Workaround: Include the Unit or Module into the main program's source:

        (*$I MyModule *)

        Program MyProg;

        uses
          MyModule;

        ...

- When `gpc` is invoked for linking only, it crashes on some systems. Workaround: Use `gcc` instead of `gpc` for linking:

        gpc -c hello.pas
        gcc -o hello hello.o -lm -lgpc

- Temporary `.gpc` files are not removed after compilation.
- The inline set operations have some problems with operations on two sets if the sets do not contain equally many segments.
- In addition, the set code generated in the Alpha causes runtime errors in the generated code.
- There are some bugs with mathematical functions. GPC fails, for example, the "Paranoia" test.
- The main program name is not capitalized. It may clash with libc identifiers which may be important but invisible for the program, e.g. ``log'`.

## Standard Pascal

- 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.
- Conformant arrays don't yet work (in general). Until they do, GPC is a Level-0 Standard Pascal compiler.

## Extended Pascal

- Schema types are not yet implemented; only String schemas work (well ... sometimes).
- String schemas as formal value parameters do not work. Workaround: Pass string types with specified capacity instead, i.e. use

        Type
          WrkString = String ( 80 );

        Procedure Foo ( S: WrkString );

  instead of

        Procedure Foo ( S: String );

- Initialized Strings and structured variables are not yet implemented.
- Illegal substrings let crash the compiler rather than triggering an error message:

        str:='1234567890';
        i:=8; j:=13;
        str:=str[i..j];

- The ``Index'` function does not work when the pattern is a char:

        Var
          C: Char;
          S: String ( 80 );
          i: Integer;

        ...

        i:= Index ( s, c );  (* "i" always zero *)

  It works with ``Var C: String ( 1 );'`

## Borland Pascal

See section From Borland Pascal to GNU PascalQuickStart Guide for Borland Pascal users.

- 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.
- Most of Borland Pascal's System Unit is not implemented, e.g. ``Byte'`, ``Pointer'`, ``LongInt'`, ``move'`, ``FillChar'`, ``BlockRead'`, ``BlockWrite'`, ``Assign'`, String-related functions, ... Workaround: Some of the missing data types, procedures and functions are implemented in a separate compatibility Unit. Check the `contrib` subdirectory of your GPC distribution.
- Initialized Strings are not yet implemented; initialized structured variables do not yet work in all cases.
- Chars like ``#13'` or ``^M'` do not work. Use ``chr ( 13 )'` instead.
- The inline assember does not follow Borland syntax.
- There is no ``private'` directive for Objects yet.
- There are no "Procedural types" but pointers to procedures instead.
- There is no ``Inline'` in Borland sense.

## GNU Extensions

- The Run Time System (RTS) does not know about modified types such as ``__byte__'` or ``__unsigned__ Integer'`s or ``__long__ Real'`s. Especially, you cannot ``writeln'` such variables. Workaround: Cast them to their basis type before ``writeln'`, e.g.

        Type
          Extended = __long__ Real;

        Var
          foo: Extended;

        [...]

        writeln ( Real ( foo ) );

## Inconveniences

- ``New'` and ``Dispose'` optional tag field arguments are ignored (warning given, code works).
- ``Gdb'` does not yet understand pascal sets, files or subranges. Now ``gdb'` allows you to debug these things, even though it does not yet understand some stabs.
- ``Packed'` does not pack. (Implementation dependent, warning given, code works.)
- 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 ``file of 0..255'`.

## Notes for debugging

- Forward referencing pointers generate ``dbx'` style debugging symbols by outputting the ``.stabs'` as an unknown pointer and later it just outputs the same ``.stabs'` again, but this time it also tells what type the pointer points to. This seems to work for ``gdb'`. As of this writing I have not checked what happens with ``sdb'` type debugging info. It might be that the pointer is left to be a `(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 ``gdb'`. If you do, please let us know what happens. I think that GDB does not yet support the kind of ``.stabs'` that should be used to do this correctly:

        .stabs ":tanumber=bnumber", whatever

  where anumber is the unknown pointer type referenced earlier, and the bnumber is the type which anumber actually is. This construct is not required in C.
- 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:

      Procedure FooBAR(i:integer);c;

  This makes the external name to be ``_foobar'` (replace `_` with you machine prefix.)

      Procedure FooBAR(i:Integer); External;

  Uses external name `_Foobar`. It is done like this to reduce name clashes with ``libc.a'` and other possible libraries.
- All visible GPC runtime system library routines are named `_p_...`.
- However, the main program name is not capitalized. (This is a kludge; see above.)

Go to the first, previous, next, last section, table of contents.