🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.delphi.language.delphi.dotnet
3 messages
3 total messages Started by Stephen Boyd Fri, 20 Jun 2008 16:01
Short Strings
#53
Author: Stephen Boyd
Date: Fri, 20 Jun 2008 16:01
39 lines
1957 bytes
I came across an interesting quirk today.  The components that I am 
converting from Win32 make use of ShortStrings with a maximum length 
specified.  Like this:

s : String[10];

Most of the time this doesn't seem to cause any problems.  But when the 
ShortString appears in the local variable list of an object's method 
calls to that method will throw an access violation.  Changing the 
ShortString to a regular String (by just removing the [10] length 
specifier) make the problem go away.  Oddly enough using the ShortString 
in a regular procedure call (not an object member) doesn't seem to cause 
the problem.

Is this a known problem?

Roughly what was happening in the code was this:

type
   TMyClass = class
   public
     procedure MyMethod;
   end;

   procedure TMyClass.MyMethod;
   var
     s: String[10];
   begin
   end;


var
   mc: TMyClass;

begin
   mc := TMyClass.Create;
   mc.MyMethod; -----------> This throws an access violation before the 
debugger can trace into the method.
end;
Re: Short Strings
#54
Author: David Capps
Date: Fri, 20 Jun 2008 16:05
28 lines
2067 bytes
On Fri, 20 Jun 2008 17:01:38 +0100, Stephen Boyd <sboydlns@gmail.com>  
wrote:

> I came across an interesting quirk today.  The components that I am  
> converting from Win32 make use of ShortStrings with a maximum length  
> specified.  Like this:
>
> s : String[10];
>
> Most of the time this doesn't seem to cause any problems.  But when the  
> ShortString appears in the local variable list of an object's method  
> calls to that method will throw an access violation.  Changing the  
> ShortString to a regular String (by just removing the [10] length  
> specifier) make the problem go away.  Oddly enough using the ShortString  
> in a regular procedure call (not an object member) doesn't seem to cause  
> the problem.
>
> Is this a known problem?

Sounds like it *may* be related to a bug I found:  
http://qc.codegear.com/wc/qcmain.aspx?d=62961

TBH support for ShortStrings in .NET seems a little unstable; I've found  
other problems in using them (like  
http://qc.codegear.com/wc/qcmain.aspx?d=62005) that make porting old code  
using ShortStrings a little risky...

-David Capps
Re: Short Strings
#55
Author: Stephen Boyd
Date: Fri, 20 Jun 2008 16:12
19 lines
1715 bytes
David Capps wrote:
> 
> Sounds like it *may* be related to a bug I found: 
> http://qc.codegear.com/wc/qcmain.aspx?d=62961
> 
> TBH support for ShortStrings in .NET seems a little unstable; I've found 
> other problems in using them (like 
> http://qc.codegear.com/wc/qcmain.aspx?d=62005) that make porting old 
> code using ShortStrings a little risky...
> 

These problems all sound vaguely related.  I guess the best advice is to 
avoid the use of ShortStrings in .Net.

Not a big problem for me.  The components don't use ShortStrings all 
that much.  Wasted a couple of hours trying to figure out what the 
problem was though.

Thanks for the info.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads