Errors, bugs, questions - page 265

 
Voodoo_King:

and don't ask me to write more details to helpdesk. this situation could and should have been caught before the build was released. you have puncture after puncture in the main areas.

Young man, if you knew what rake people here have stepped on...

Secondly, the Developers don't sell in real life.


So wipe the drool, write an application (in the application you can scold the developers for being so bad).

But something has to be done.

 
Thank you, we'll look into it.
 

I would like to ask (I haven't encountered this problem before for some reason)...

Is this kind of construct entirely up to the programmer (looping when an unsigned number overflows)?

   uchar LastBarInd = 2;
   for (uchar i = LastBarInd; i >= 0; i--)
     {
      ................. // тело
     }

Or can it be fixed in the compiler?

 
AlexSTAL:

I would like to ask (I haven't encountered this problem before for some reason)...

Does a construct of this kind fall entirely on the programmer (looping when an unsigned number overflows)?

Or can it be tweaked in the compiler?


It falls entirely on the programmer.

The most that can be done in the compiler is a warning.

 
stringo:

This is entirely up to the programmer.

The most that can be done in a compiler is a warning.

Well a warning wouldn't hurt, please do.
 
AlexSTAL:
Well a warning wouldn't hurt, please do.

made

void OnStart()
  {
   uchar LastBarInd;
   Print(LastBarInd>=0);
   Print(LastBarInd<0);
  }

// expression is always true    1.mq5   4       20
// expression is always false   1.mq5   5       20
 
mql5:

made

Sorry... I don't understand...

What does LastBarInd have to do with subtracting one from zero for an unsigned number in a loop?

Uchar  i >= 0; i--
 
AlexSTAL:

Sorry... I don't understand...

What does LastBarInd have to do with subtracting one from zero for an unsigned number in the loop?


And you want the compiler to calculate in advance all possible values the i variable can take and give you a warning?

SZZ The compiler already has a lot of work to do, so it has to watch for programmer's blunders.

There will probably be an error at runtime.

 
AlexSTAL:

Sorry... I don't understand...

What does LastBarInd have to do with subtracting one from zero for an unsigned number in the loop?


The problem with looping isn't the way it's changed (unless of course it's changed to zero), it's checking the value of that variable, which will never be less than zero.

void OnStart()
  {
   uchar v;
   Print(v>=0);
   Print(v<0);
  }
 
Urain:

Do you want the compiler to calculate in advance the values the i variable can take and give you a warning?

SZZ The compiler already has a lot of work to do, so it has to watch for programmer's blunders.

ZS The error will probably occur, but at runtime.

No... I meant a special case when:

1) Type of variable i is unsigned.

2) An explicit constant

i >= 0

3) subtraction

i--