[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: gcc: A while Loop Always Skips its first Statement.



On 2010-08-20 08:01:46 -0500, Martin McCormick wrote:
[...]
> 	Reading about the while loop tells me that the statement

Actually, that's an expression, not a statement.

> after while must be true to execute. If I put a boolean variable
> inside the statement as in (NEXTSYS) does that make a true
> statement if it is not 0 and false if it is?

There's a 3rd possibility: you have an undefined behavior, e.g.
because the expression uses an uninitialized value, in which case
the compiler can assume anything, and debugging with gdb wouldn't
necessarily help.

Just in case, compile with -Wall, and -O0 if you want to use gdb.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)


Reply to: