[fpc-pascal] weird compiler(?) problem

Xiangrong Fang xrfang at gmail.com
Thu Feb 13 17:28:59 CET 2014


2014-02-14 0:16 GMT+08:00 Martin Frb <lazarus at mfriebe.de>:

>
> Is it just the debugger does not stop? But the statement is executed
> (stopping in the next line never happens with FCount >= 2)?
>
> Check your setup
> http://wiki.lazarus.freepascal.org/Debugger_Setup
> - NO smartlinking
> - NO optimization
>   -O1 is often, but not always ok, so if there is an issue, then use -O-
>
> Your image does not show the "blue dots" in the gutter (where the
> breakpoint ,and green arrow are). That indicates there is something wrong
> with the debug info.
>
> Or maybe you have 2 units of the same name ,and use relative path ( ../ )?
> This can cause problems in some cases. Because gdb does not always deal
> with the .. , and then the IDE must specify the unit by name only, which is
> ambiguous.
>

​Debugger problem is minor.  I know I am missing the blue dots here. But
the MAJOR problem is that in the attached screenshot, FCount is 0, which is
of course smaller than 2, but it does NOT Exit!

This caused a SIGSEGV because in the code below I do this:

last := FCount - 1;
FItems[last] ...      //<-- which results in FItems[-1];

And smartlinking never turned on, switching off optimization in lazarus
does not help either.

Regards,
Xiangrong​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140214/16ece953/attachment.html>


More information about the fpc-pascal mailing list