Delphi 10.3 Rio - Is initializaiton of inline declared record variables needed?

前端 未结 1 2049
陌清茗
陌清茗 2021-01-17 23:00

I am quite excited about Delphi 10.3 Rio inline variable declarations. However I ran into strange problem and it seems that I need to initialize record after it has been inl

相关标签:
1条回答
  • 2021-01-17 23:38

    I took a look in the CPU window and found a few oddities.

    If I use the old-style var-block (your version // A), the CPU window shows a call to System._InitializeRecord, as it should. All is fine and normal.

    If I use the inline declaration with Default() (your version // B), the local record is nilled out, then finalized using System._FinalizeRecord and then nilled out again. That is pretty weird and useless, but it works.

    But if I use your version // C, nothing is done to initialize the record: no nilling out, no _InitializeRecord. When I tested your code, things did work, but I was probably just lucky.

    So this is clearly a bug. Please report it to the Embarcadero Quality Portal.


    I guess this is a remainder of the changes made to the compiler when default constructors, default destructors and overloaded assignment operators were tested (but then removed and postponed to a next release). Some of these changes were rather braindead (like the nilling, finalization and nilling again, as in version B), and I guess some of these changes were forgotten.

    Update

    Obviously this was already reported to QP:

    • https://quality.embarcadero.com/browse/RSP-21632
    • https://quality.embarcadero.com/browse/RSP-23417
    • https://quality.embarcadero.com/browse/RSP-23747
    0 讨论(0)
提交回复
热议问题