Errors, bugs, questions - page 2762

 
Igor Makanu:

checked:

OK, works without any compiler warnings

Thanks

You'll laugh, but even that works without any warnings

uchar c[16];
int ini2=0xFFFF;
ArrayInitialize(c, (uchar)ini2);
 
Aleksey Mavrin:

You'll laugh, but even this works without warnings

you'll laugh too, but it's the way to UB and the way to get the tricky bug on the next builds :-)

int foo=-1;

uchar bar=(uchar)foo; // чему должен быть равен bar ?

 
Igor Makanu:

checked:

OK, works without any compiler warnings

Thanks

Why is the ArrayInitialize call needed in this case? Why not just write uchar uc[16] = {0xFF}; ?

ArrayInitialize makes sense for dynamically distributed arrays, while here the size is supposedly known at the time of description.

 
Aleksey Mavrin:

You will laugh, but even this works without any warnings

it's not funny, it's not correct initialization, which you may not understand why you did

it's clear that the high byte will be truncated when casting to uchar


Stanislav Korotky:

Why do I need ArrayInitialize call in this case? Why not just write uchar uc[16] = {0xFF}; ?

ArrayInitialize makes sense for dynamically distributed arrays and here the size is supposedly known at the moment of description.

won't work

Unprint it, the first element will be 255 and the rest 0, 0, 0, ...

 
Igor Makanu:

OK, works without any compiler warnings

without a ghosting is normally like this

ArrayInitialize(uc, '\xFF');
UPD no, same warning, such a literal is of type ushort
 
Once again, on an even keel...
void OnStart(){
   uchar uc[16];
   ArrayInitialize (uc, -1);
   ArrayPrint(uc);  // 255 255 255 255 255 ...
}
 
Sergey Dzyublik :
Once again, on a level playing field...
What's the problem?
 
Sergey Dzyublik:
Once again on the spot...

I'm totally confused )

It warns about constants from 128 and 0xFF, but not about int variables with the same values.

Moreover, it doesn't warn about constant -1 int either. Is there some logic in this?

s.s. I guess it's understandable with -1, it's reduced to any unsigned by max value according to the rules.
 
Andrei Trukhanovich:

without a ghost like that.

UPD no, also a warning, such a literal is of type ushort
'\xFF'

?? wow... in 4 (it's open on occasion) rolls.

void OnStart()
  {
ushort foo='\xFF';

  }

PS/ when on occasion, whoever has a web site near you, give them a slap on the wrist.

 
In build 2460 and 2470 when you delete all trades and disable auto-refresh and open a new order they all reappear before this did not happen and part of the advisors and indicators writes err 400 and err 401 although they compile without error but do not want to work.....
Reason: