[fpc-pascal] weird compiler(?) problem

Martin Frb lazarus at mfriebe.de
Thu Feb 13 17:16:53 CET 2014


On 13/02/2014 15:42, Xiangrong Fang wrote:
> Hi All,
>
> I encountered a very strange problem.  The code looks like this:
>
> //In Unit1.pas:
>
> //sel is an object of TIntVector and
> //TIntVector = specialize TVector<Integer>
> *sel.Sort([soEliminateNA, soReversed]);
> *
>
> //In vector.pas:
>
> procedure TVector.Sort(Options: SortOptions);
> var
>   i, gap, order, first, last, pos: Integer;
>   Temp: T;
> begin
> *if FCount < 2 then** Exit;  <-- problem here*
>   if soReversed in Options then order := 1 else order := -1;
>   ... ...
>
> My purpose is to skip sorting if the vector's element count is less 
> than 2.
>
> Now the problem is that this statement does not have any effect (see 
> attached screenshot).  The debugger refuse to stop on the breakpoint, 
> but goes directly to the line below it!
>

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140213/a43ba464/attachment.html>


More information about the fpc-pascal mailing list