Quantcast
Channel: Delphi – The Wiert Corner – irregular stream of stuff
Viewing all articles
Browse latest Browse all 1440

Delphi function result assignments before the function returns…

$
0
0

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


Viewing all articles
Browse latest Browse all 1440

Trending Articles