Today features a subtle bug from Wanderer:
cg->moveflag_dest = HUD_VAR(custom_gauge_moveflags) + (Num_custom_gauges * sizeof(bool));
How many bugs can you spot?
NB: HUD_VAR is a macro resolving to offsetof
Even at the risk of making myself look like a donkey, I think there are at least three.
Could you post the assigned datatypes of this snippet? What is custom_gauge_moveflags supposed to be? A boolean? I have never seen anything related to FSOpen, and can't bother to download the thing yet to check it for myself.
My guess is that this is written C++? I don't remember the boolean definition in it, but looks like if moveflag_dest is boolean (one bit for a yes/no flag?), the result of the right hand side can become something else.
Num_custom_gauges is probably integer and may become greater than 1, yet it multiplied by sizeof(bool)? Thus resulting in integer/garbage?
HUD_VAR is a macro operating to a vector (or worse, a pointer)? I don't know exactly if this is an error here, but generally macros tend to result in disasters if coder isn't exactly sure how C expands them. Especially if it has something like SOME_MACRO( int c + int b)...
What is Num_custom_gauges * sizeof(bool) even supposed to do?