Can anyone remind me what are the criteria for SDCC issuing the infamous
"conditional flow changed by optimizer..." warnings? I used to have some
idea, but I've forgotten these days. Something to do with unreachable
code or inversion of logic?
I have been getting these warnings for some code, but I fail to see how
the generated assembly code logic or flow does not match that of the C
code being compiled.
My C code is as follows:
typedef struct {
uint8_t history;
bool pressed : 1;
bool released : 1;
bool down : 1;
bool up : 1;
uint8_t : 4;
} foo_state_t;
bool foo_is_up(foo_state_t *state) {
return (state->up && (state->up = false, true)); // <-- warning on this
}
The generated STM8 assembly code is as follows:
_foo_is_up:
incw x
ld a, (x)
bcp a, #8
jreq 00103$
ld a, (x)
and a, #0xf7
ld (x), a
jra 00104$
00103$:
clr a
ret
00104$:
ld a, #0x01
ret
As far as I can see, this assembly code is doing exactly what the C code
is intending. Increment argument pointer to 2nd byte of struct. Mask and
compare the 'up' bit to zero. If zero, return false. Otherwise, mask out
'up' bit to set it to false, and return true.
Where is the supposed change in conditional flow? It seems to be warning
about nothing.
Regards,
Basil Hussain
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user