It's not the compiler's job to tell you what you want, it's your job
to tell it! The -Wall flag doesn't mean, "warn me about every
possible stupid construct I can come up with."
In all seriousness, if you don't get over using a "greater than or
equal" construct for loop termination, you're going
Actually, it is likely that the compiler did notice, and optimized your
unsigned comparison away completely, effectively leaving a true infinite loop
in the machine code.
Brian Lavender wrote:
>On Tue, Apr 20, 2010 at 06:54:33PM -0700, Bill Broadley wrote:
>> On 04/20/2010 06:37 PM, Brian Lave
On 4/20/10 7:44 PM, Brian Lavender wrote:
> Thus, I am thinking that the compiler could catch this due to the
> fact that i is unsigned. I wanted to print out the reverse of an
> array.
The problem with this is two-fold. First, writing a loop that may never
terminate isn't necessarily a bug -- c
On Tue, Apr 20, 2010 at 06:54:33PM -0700, Bill Broadley wrote:
> On 04/20/2010 06:37 PM, Brian Lavender wrote:
> > Our new guy (forget his name, doh!) and I figured out the problem with
> > my loop that would count down, but not terminate. Turns out I was using
> > an unsigned integer for my counte
On 04/20/2010 06:37 PM, Brian Lavender wrote:
> Our new guy (forget his name, doh!) and I figured out the problem with
> my loop that would count down, but not terminate. Turns out I was using
> an unsigned integer for my counter in my for loop and it is always
> greater than zero (Example 1).
No,
Our new guy (forget his name, doh!) and I figured out the problem with
my loop that would count down, but not terminate. Turns out I was using
an unsigned integer for my counter in my for loop and it is always
greater than zero (Example 1).
Funny thing is that -Wall didn't catch this. Seems that -