Compiler Bug?

From: Christian Jabs <jabs_at_voelkel.de>
Date: Thu, 06 Jul 2000 10:42:17 +0200

I think I found a compiler bug that occurs in BCB3 and BCB5 (so I think
it also in BCB4, but I can't prove it).

Try the following two snippets (it should remove spaces from a String):

/----- snip1 ----------------------------/
AnsiString s="Test Test";

while( int Pos = s.AnsiPos(" ") )
{
   s = s.SubString(1, Pos - 1) + s.SubString(Pos + 1, s.Length() - Pos);
}
/----- end snip1 ------------------------/

/----- snip2 ----------------------------/
AnsiString s="Test Test";

while( int Pos = s.AnsiPos(" ") )
   s = s.SubString(1, Pos - 1) + s.SubString(Pos + 1, s.Length() - Pos);

/----- end snip1 ------------------------/

I would think the assembler code generated by these two snippets are
equal
(or at least equivalent). But in snip2 the code does not behave like one
could think. You can simply see it if you set s to an empty string
(s=""). Though the result in the while inquiry is zero (or false) it
enters the following line.

Is there s.th. wrong in my train of thoughts?

Christian
Received on Thu Jul 06 2000 - 10:14:25 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:40 NZDT