Recent

Author Topic: Nil value on assignment of '' ?  (Read 1673 times)

aducom

  • Full Member
  • ***
  • Posts: 159
    • http://www.aducom.com
Re: Nil value on assignment of '' ?
« Reply #15 on: February 28, 2024, 07:00:56 pm »
@Thaddy, sometimes, reproducing is hard. I expected to have some kind of compiler setting to be wrong. It was not my intention to get a bunch of rants here.

Thaddy

  • Hero Member
  • *****
  • Posts: 16152
  • Censorship about opinions does not belong here.
Re: Nil value on assignment of '' ?
« Reply #16 on: February 28, 2024, 07:03:22 pm »
if you Access STRING - then the CompilerProc fpc_ansistr_assign will be involved:
No. Only for AnsiStrings. NOT for any other supported string type,
If I smell bad code it usually is bad code and that includes my own code.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10549
  • Debugger - SynEdit - and more
    • wiki
Re: Nil value on assignment of '' ?
« Reply #17 on: February 28, 2024, 07:35:31 pm »
Can you try to compile with NO optimization (Project options > Compilation and linking).

or alternatively put this in your code (right after the unit line)
Code: Pascal  [Select][+][-]
  1. unit my_unit;
  2. {$Optimization PEEPHOLE off}

There is a tiny chance that might help.


Also just to be sure => in your examples you have just one or two local vars => in your real code, is it about a local variable too? or maybe a field in an object "form1.mystring" ?

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1428
    • Lebeau Software
Re: Nil value on assignment of '' ? {closed}
« Reply #18 on: February 28, 2024, 11:44:03 pm »
The variable is not static, declaring it static fixed the issue for me. Lesson learned.

That just sounds like a band-aid, not a real solution.  I still stand by my earlier assessment that you were likely accessing the string via an invalid pointer.  But, without seeing the real code, anything that anyone says is just speculation.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11935
  • FPC developer.
Re: Nil value on assignment of '' ? {closed}
« Reply #19 on: February 29, 2024, 10:58:33 am »
That just sounds like a band-aid, not a real solution.  I still stand by my earlier assessment that you were likely accessing the string via an invalid pointer.  But, without seeing the real code, anything that anyone says is just speculation.

Calling a method on something that isn't a proper instance of the class, yes, that is what I think also.

 

TinyPortal © 2005-2018