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.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to