Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
13.5 for() loops - does simplicity matter?
#1
I have compiled the following code. The compiler accepts the first loop (ending at X) but rejects the other two (ending at X+2 and at X*2)

extern tUI16 X, Y;
void Fn( void )
{
tUI16 i;
for( i = 0u; i < X; i++ ) /* accepted */
{
Y += i;
}
for( i = 0u; i < (X + 2u); i++ ) /* rejected */
{
Y += i;
}
for( i = 0u; i < (X * 2u); i++ ) /* rejected */
{
Y += i;
}
}

The compiler suppliers say the compiler will accept the second expression if it is "a simple test" and that X+2 and X*2 do not pass this test. I feel this is being too restrictive for rule 13.5. Please may I have an opinion on this.

Thanks,

John
<t></t>
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)