View Issue Details

IDProjectCategoryView StatusLast Update
0030720FPCFCLpublic2016-11-12 22:56
ReporterMichalis KamburelisAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformx86-64OSDebian GNU/LinuxOS Version(testing)
Product Version3.1.1Product Build34702 
Target Version3.2.0Fixed in Version3.1.1 
Summary0030720: fcl-passrc fails when you use some characters in an inactive code part
DescriptionFPC ignores everything inside

{$ifdef NEVER_DEFINED}
...
{$endif}

if the "NEVER_DEFINED" is not defined.

fcl-passrc fails when the "..." part contains something really weird (not recognized by the tokenizer, it seems), like "}" or "|" or "ą" (local Polish letter -- "a" with a "tail").

It seems that fcl-passrc treats all such characters as an unexpected end of file.

$ fpc trying_to_scan_not_active_code.lpr
$ ./test_passrc trying_to_scan_not_active_code.lpr
An unhandled exception occurred at $0000000000477825:
EParserError: Syntax error at token "EOF" in file trying_to_scan_not_active_code.lpr at line 6 column 1
TagsNo tags attached.
Fixed in Revision34879
FPCOldBugId
FPCTarget
Attached Files

Activities

Michalis Kamburelis

2016-10-10 02:06

reporter  

trying_to_scan_not_active_code.lpr (198 bytes)

Michalis Kamburelis

2016-10-10 02:07

reporter  

test_passrc.lpr (2,184 bytes)

Michael Van Canneyt

2016-10-22 16:21

administrator   ~0095260

Tested on your source and in test case: illegal characters are simply skipped. Your test program does not give an error either.

Michael Van Canneyt

2016-10-22 16:21

administrator   ~0095261

You can see for yourself: See line 1967 of pscanner.pp

Michalis Kamburelis

2016-10-24 12:09

reporter   ~0095310

Last edited: 2016-10-24 12:09

View 2 revisions

I can still reproduce it, with both FPC 3.1.1 (latest trunk as of today) and 3.0.0, with units compiled in release mode. (I compile and install FPC trunk by simple "make clean all install INSTALL_PREFIX=...", with FPC 3.0.0 as starting compiler).

After a bit of testing, it seems a bug in the optimizer!

- I removed any fcl-passrc units from my -Fu.

- Compiling and using fcl-passrc without optimizations indeed works without any problems:

  $ rm -f /home/michalis/sources/fpc/trunk/packages/fcl-passrc/src/*.{ppu,o,rsj}
  $ fpc -Fu/home/michalis/sources/fpc/trunk/packages/fcl-passrc/src/ test_passrc.lpr
  $ ./test_passrc trying_to_scan_not_active_code.lpr
  No interface section --- this is not a unit, this is a TPasProgram

- Compiling and using fcl-passrc with -O2 reveals the bug:

  $ rm -f /home/michalis/sources/fpc/trunk/packages/fcl-passrc/src/*.{ppu,o,rsj}
  $ fpc -O2 -Fu/home/michalis/sources/fpc/trunk/packages/fcl-passrc/src/ test_passrc.lpr
  $ ./test_passrc trying_to_scan_not_active_code.lpr
  An unhandled exception occurred at $0000000000476F05:
  EParserError: Syntax error at token "EOF" in file trying_to_scan_not_active_code.lpr at line 6 column 1
    $0000000000476F05
    $0000000000476E1D

So, the addition of -O2 makes the code in fcl-passrc behave differently (and buggy). I rechecked this with both FPC 3.1.1 (revision 34762) and FPC 3.0.0. Without -O2, the bug disappears.

This is all tested on Linux/x86_64 (Ubuntu 16.04.1). I did not test other platforms.

Michael Van Canneyt

2016-11-12 22:56

administrator   ~0095806

Did some more debugging. The problem was the spurious } in the source.
I fixed it. Thanks for reporting!

Issue History

Date Modified Username Field Change
2016-10-10 02:06 Michalis Kamburelis New Issue
2016-10-10 02:06 Michalis Kamburelis File Added: trying_to_scan_not_active_code.lpr
2016-10-10 02:07 Michalis Kamburelis File Added: test_passrc.lpr
2016-10-10 08:09 Michael Van Canneyt Assigned To => Michael Van Canneyt
2016-10-10 08:09 Michael Van Canneyt Status new => assigned
2016-10-22 16:21 Michael Van Canneyt Note Added: 0095260
2016-10-22 16:21 Michael Van Canneyt Status assigned => resolved
2016-10-22 16:21 Michael Van Canneyt Resolution open => unable to reproduce
2016-10-22 16:21 Michael Van Canneyt Note Added: 0095261
2016-10-24 12:09 Michalis Kamburelis Note Added: 0095310
2016-10-24 12:09 Michalis Kamburelis Status resolved => feedback
2016-10-24 12:09 Michalis Kamburelis Resolution unable to reproduce => reopened
2016-10-24 12:09 Michalis Kamburelis Note Edited: 0095310 View Revisions
2016-11-12 22:56 Michael Van Canneyt Fixed in Revision => 34879
2016-11-12 22:56 Michael Van Canneyt Note Added: 0095806
2016-11-12 22:56 Michael Van Canneyt Status feedback => resolved
2016-11-12 22:56 Michael Van Canneyt Fixed in Version => 3.1.1
2016-11-12 22:56 Michael Van Canneyt Resolution reopened => fixed
2016-11-12 22:56 Michael Van Canneyt Target Version => 3.2.0