Recent

Author Topic: Inline functions out variable of string bug  (Read 1077 times)

Warfley

  • Hero Member
  • *****
  • Posts: 1499
Inline functions out variable of string bug
« on: August 01, 2020, 06:34:25 pm »
I've found a pretty weird bug when using inline functions:
Code: Pascal  [Select][+][-]
  1. program Project1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. procedure foo(out c: char); inline;
  6. begin
  7.   c := #32;
  8. end;
  9.  
  10. var s: String;
  11.  
  12. begin
  13.   s:=#42;
  14.   foo(s[1]);
  15.   Writeln(ord(s[1]));
  16. end.  

The contents of s does not change (i.e. the output is 42). When removing the "inline" it works

Is this already known or shall I file a bug report? Also would be nice if someone could reproduce this bug

PascalDragon

  • Hero Member
  • *****
  • Posts: 5481
  • Compiler Developer
Re: Inline functions out variable of string bug
« Reply #1 on: August 01, 2020, 07:09:05 pm »
I can reproduce it. Please report.

Warfley

  • Hero Member
  • *****
  • Posts: 1499
Re: Inline functions out variable of string bug
« Reply #2 on: August 01, 2020, 07:47:52 pm »
ok, reported

jamie

  • Hero Member
  • *****
  • Posts: 6130
Re: Inline functions out variable of string bug
« Reply #3 on: August 01, 2020, 09:32:17 pm »
I gave you a thank you btw..

I think it may have pointed me in a direction of a failing set of DLLS I attempted to compile with 3.2.0 that didn't error out at compile or runtime but just returned bad data and I do use code like that! inlines with OUTS in an attempt to compress the baggage due to the nature of the operations..


 I
The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 6130
Re: Inline functions out variable of string bug
« Reply #4 on: August 02, 2020, 03:46:17 pm »
I found two places in the DLL's files where I use string operations like that, removed the INLINE and those sections of code now works but I still have corrupted data in other parts of the files and doing that same type of code with dynamic arrays of byte seems to work ok using the inline so I am still on a search for the remaining errors.

 To recap on the case, these files work perfectly with 3.0.4. I switched to using inline coding because my older Delphi compiler didn't have that so when I switched to fpc I had to do some coding in an attempt to speed up the execution time because that was one of the items I noticed was slower than Delphi's code.. I used the Delphi DLL's for a while with Lazarus then fully compiled over to fpc because I wanted to keep is fully fpc code compliant .

The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018