Array of const is a great tool to write custom formatting / string concatenation functions. You put anything in square brackets, in any quantities, your function receives what it sees as a dynamic array of variant.
Now there's a funny pitfall with trash pointers. Usually if you use trash pointers to make values, the crash happens at the call to your function and the cause is pretty clear.
But! If you are unlucky to feed your function a dereferenced trash pointer to a shortstring (can come from invalid dechiphering of RTTI)... Variant uses shortstrings as a pointer to a shortstring. So the code that manages the call does not actually dereference. It uses your trash pointer as is, inserting it into a now broken variant, then passes it to your function without causing any effects.
The crash then happens *inside* of your function when it tries parsing that broken variant and finally accesses the memory the trash pointer points to. AV.
This is harder to find cause of -- and if it happens that your function was in the core of your error processing mechanism... Boom! The whole system collapses leaving you without a clue to what had caused the crash. No backtrace, no error message (it was trying to compose it using that broken RTTI info).
Have fun debugging
Bookmarks