This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] sim: add --map-info option


> > Wouldn't it make sense to hoist the assignment to memory out of
> > the for initial assignment? It's never changed during the loop...
> 
> i dont understand ... isnt this the whole purpose of the first clause
> of the for statement ?  initializing things once that dont change
> inside of the loop.  

The code works, and I'm fine if you really want to keep it that way.
But you said "initializing things once that dont change inside of the
loop" and that is not true.  You would typically initialize the
variables used in the looping condition, and these variables change
at each iteration.

But that's beside the point, and I don't think there is anything in
the C language that says what should should do, or should not do.  All
I am saying is that you are doing something unusual: You are initializing
in that clause a variable that is never changed during the loop, nor
referenced in the other two clauses of your for statement. If I was
maintaining the code, I would find it much clearer to initialize
the variable before the loop, and then write a typical "for (...)"
statement.

-- 
Joel


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]