Recent

Author Topic: DebugInfo: wrong line numbers on variables init ?  (Read 415 times)

Arioch

  • Sr. Member
  • ****
  • Posts: 421
DebugInfo: wrong line numbers on variables init ?
« on: March 19, 2023, 08:32:04 pm »
See screenshots, see RAX register value.

VAR-init is being executed, but CONST-section is instead emitted into the DebugInfo

Win64 trunk FPC/Laz, DWARF 3 mode

Code: Pascal  [Select][+][-]
  1. procedure Test(const Recur: integer);
  2. const
  3.   cVar: integer = 30;
  4. var
  5.   initted: integer = 20;
  6.   regular: integer;
  7. begin
  8.   Inc(regular);
  9.  



A tangential question: since there is anyway the code lines explicitly emitted, why limiting it to constant values, why not allowing a full-fledged expressions, like

Code: Pascal  [Select][+][-]
  1. var gVar: integer = 10;
  2.  
  3. function M(): integer; begin result := gVar + 100; end;
  4.  
  5. procedure Test(const Recur: integer);
  6. const
  7.   cVar: integer = M(); // 30;
  8. var
  9.   initted: integer = M();// 20;

Implementing this would probably be naturally re-used later when you would be implementing Delphi XE11's Scoped/Inline variables.
« Last Edit: March 19, 2023, 08:33:50 pm by Arioch »

 

TinyPortal © 2005-2018