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
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!