[fpc-pascal]Bug in parsing ASM statements with braces in string literals

Rich Pasco pasco at acm.org
Fri Nov 10 22:41:06 CET 2000

There seems to be a bug in the parser when targeting ASM statements
for a WIN32 target.  I'm using Free Pascal Compiler version 1.0.2
[2000/10/12] for i386.

The parser does not properly handle literal strings inside assembler
DB statements, when the strings contain brace characters.  The compiler-
generated code omits the braces and any characters between them.

Interestingly, this is not a problem for braces in strings elsewhere in
the program, only for those in assembler DB statements.

For example, consider the code snippet which embeds a bit of PostScript
code in an assembly-language segment:

    db '/pop2 { pop pop } def',0;

This construct works correctly under Borland Pascal 7.0, where the
resulting PostScript string is "/pop2 { pop pop } def".  But under Free
Pascal, the string is just "/pop2  def" which, obviously, causes the
resulting PostScript to be invalid.

Below is the minimal compilable program that demonstrates this problem.
Try it under Borland Pascal and then under Free Pascal to see the

procedure SomePostScript; assembler;
    db '/pop2 { pop pop } def',0;

Of course, I am aware that I could work around the bug by re-coding my
statement as

    db '/pop2 ',123,' pop pop ',125,' def',0;

However, my point is not to ask for help in developing my application,
but to alert you to a bug in the parser that should be fixed.

     - Rich

More information about the fpc-pascal mailing list