Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TList - Corrupted Data Problem 1

Status
Not open for further replies.

Glenn9999

Programmer
Jun 19, 2004
2,311
US
I'm using a TList with some specific records and I'm running into a problem (TD2006). What I'm putting into it is something like this:

Code:
Myrecord = record
  A: String[255];
  B: String[255];
  C: String[50];
  D: String[50];
  E: Extended;
end;

But when I get it out, I get messed up data in E, resulting in a floating-point exception. Now I tried tracing it through my code and noticed that E wasn't getting overwritten BEFORE I added the record, and even proved that by overwriting it with a uniform character before I started processing it. The curious part to me is that I can move E to any other position in the record and have it work absolutely properly with no indications that any data got corrupted at any point. When D is in the final position, I notice no data corruption whatsoever in that value.

I've run out of all the things I know to look for in my code (something overwriting the data beyond it's bounds, namely). Any thoughts on things to look at (as obviously there's something wrong somewhere if E in that position is getting corrupted)?

 
OK hammered on this a while and figured it out. Still no explanation for why, but here goes. I had this in an interface, so ended up pulling the class out and testing it. Works perfectly. So guess what I did to finally get it to work smoothly (at least so far)?

Code:
Myrecord = packed record
  A: String[255];
  B: String[255];
  C: String[50];
  D: String[50];
  E: Extended;
end;

Riddle me that, did that and the interface itself worked perfectly from thereon (as far as I could tell). So....why is this?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top