[DUG] Is it a bug in latest version of Delphi?

Jolyon Smith jsmith at deltics.co.nz
Tue Feb 16 09:52:28 NZDT 2010


There is no possible way that I can see that “ShowMessage()” could yield a “List Index out of bounds” error.

 

I suspect you must have made a mistake in representing the code.  This clearly isn’t simply copied and pasted from a working test case as there is a fundamental compilation issue with an incorrectly delimited string in the 3rd AddObject() call.

 

Once that compilation issue is fixed this code compiles and works fine in BDS2006.  It is unlikely that a bug was introduced in Delphi 6, fixed in Delphi 7/2006 and then regressed in D2007 (although I wouldn’t rule it out completely).

 

From: delphi-bounces at delphi.org.nz [mailto:delphi-bounces at delphi.org.nz] On Behalf Of sinu sudhakaran
Sent: Tuesday, 16 February 2010 9:22 a.m.
To: delphi at delphi.org.nz
Cc: John.Hansen at wizbang.co.nz; Delio.Azevedo at wizbang.co.nz; Richard.Crowle at wizbang.co.nz; James.Stainton at wizbang.co.nz; SinuSudhakaran at wizbang.co.nz
Subject: [DUG] Is it a bug in latest version of Delphi?

 

Hi all,

I came across a strange bug(???) in latest versions of Delphi.

Have a look at the following code.

procedure TForm1.Button1Click(Sender: TObject);
var
i : integer;
begin
ComboBox1.Clear;
ComboBox1.Items.AddObject('All Locations', TObject(-1));
ComboBox1.Items.AddObject('Only this Location', TObject(0));
ComboBox1.Items.AddObject(Test Location', TObject(1));

i := Integer(ComboBox1.Items.Objects[0]);
showmessage(inttostr(i));
end;

When I tried to run this code in Delphi 6 and Delphi 2007 , I am getting List Index out of bounds[0] error in Showmessage. When I tried -2, -3, -4… instead of -1 object , I got the proper output without any 
List index out of bounds error. Also I am getting -1 without any error when I tried this code in Delphi 3. 

Is it a bug in latest version of Delphi ? Any help is appreciated.

Thank you

Regards,
Sinu


 <http://sigads.rediff.com/RealMedia/ads/click_nx.ads/www.rediffmail.com/signatureline.htm@Middle?> Image removed by sender.

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20100216/8a35026f/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 823 bytes
Desc: not available
Url : http://listserver.123.net.nz/pipermail/delphi/attachments/20100216/8a35026f/attachment.jpe 


More information about the Delphi mailing list