From: Paul Jakma (paulj at domain itg.ie)
Date: Wed 10 May 2000 - 18:40:59 IST
On Wed, 10 May 2000, Frank Peelo wrote:
> Sorry if this reply is totally daft; I haven't used gcc, nor have I
> programmed on Linux/Unix. But I wonder how you determined the value of input
> at the two points?
printf.
> I saw an optimising compiler, where variables could
> sometimes be shuffled around in a way that could confuse the debugger, so it
> occurs to me that either
> a) the debugger may not be telling the truth, or
> b) the compiler may have determined that it does not need to know the value
> of input and has therefore discarded it.
it is indeed possible. but in this case 'input' can't be static - it's
read in by scanf at each iteration of the do loop, and that value is used
as an index to another array, so gcc can't optimise it completely away. :)
as for the printf, it might not happen in the code as it's written in C,
but the apparent result to the user should be as it's expected to be from
the C source, shouldn't it?
anyway.. the real problem was mine. it works fine regardless of
optimisation once you actually declare the array properly. :)
--paulj
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:06:06 GMT