In the code that I support, I found some code examples that look like this:
Description := IfThen(Assigned(Widget), Widget.Description, 'No Widget');
I expected this to work when the widget is zero, but when I tested it, it worked great.
If I recompile it with the code control disabled in Project - Options - Compiler, I get an access violation.
It seems that since IfThen is marked as inline, the compiler usually does not evaluate Widget.Description if Widget is zero.
Is there a reason why the code should be “fixed” because it does not seem to be broken? They do not want the code to be changed unnecessarily. Could this bite them?
I tested it with Delphi XE2 and XE6.
source
share