The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,649 other followers

Delphi function result assignments before the function returns…

Posted by jpluimers on 2019/05/01

Eric Grange:

Actually it is not that assignments of function return values can happen “when the function raises an exception” but rather than they can happen before the function returns.

Note that this is not limited to large return types, it can also happen on reference counted types (string, dynamic array, variant and interface), though this is contextual as well…

Got bit by the interface thing a few months ago, an interface release was triggering an exception when the result was assigned, the call stack looked way out of synch with the code, so various compilation and and map file mismatch issues got investigated, before I dropped in asm view in the debugger, which made it all obvious.

I’ve quoted it in full as I’ve been bitten by this a few times as well, but never got to making a proper blog post on it.

Thanks Eric for phrasing this and David for bringing it up.

It actually has been the case since somewhere toward the end of the Turbo Pascal era.

Source: [WayBackThis program: {$APPTYPE CONSOLE} uses System.SysUtils; type TRec1 = r…

–jeroen

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
%d bloggers like this: