Inaccesible value

can anyone tell me what is causing the variable become inccesible value
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I have this problem when optimization is turned on. Trying to view a variable that has gone out of scope will also do this.
When optimization is turned on, the compiler does things
that are not obvious from the pascal lines you have written. For example, when you use a local variable only in the first
three lines of a procedure that is 20 lines long, the
compiler might detect that this value is not required
any more (altough YOU might want to see in the debugger)
and could (for example) re-use the processor register that
where it was stored for some other variable. In reality,
this is far more complex than this example, and cannot be easily predicted. The same applies for variables that go out of scope: the compiler does not need them as long as they are out of scope, so the code to make them available might
be removed by the compiler.
The one and only solution (applies to all compilers with
optimization, not just delphi): Turn optimization off
while debugging! In fact, optimized code can be so
complex to "understand" that debuggers sometimes
even have real problems when trying to step through optimized code (missing breakpoints etc.). You will
also see that you have much more "blue dots" where you
can place a breakpoint when optimization is off.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.