Jump to content

Compiler warning


robinfawell

Recommended Posts

I get a compiler warning referring to the "switch (group)" line below.

"main.c:262:warning 110: conditional flow changed by optomizer: so said EVELYN to the modified DOG"

Here is my code

unsigned char group;//used for switch statement

void DIN_NotifyToggle(unsigned char pin, unsigned char pin_value) __wparam

{

unsigned char stored_pin;

void DIN_NotifyToggle(unsigned char pin, unsigned char pin_value) __wparam

if (pin_value == 0){// only react when switch is pressed

if ((pin >= 1) && (pin <= 5))

group = 1;

if (pin == 7)

group = 2;

        more code

 

switch (group)

{case (1) :{

{

stored_pin = memory_group_stored_pin;// change value of stored pin to the memory group stored value

stored_pin = SetLed_NoDump(1, 5, 9,stored_pin, pin, pin_value); //function, set pin_low to 0, pin_high to 5, canc_pin to 9

memory_group_stored_pin = stored_pin;//resets the variable for this group to the current stored pin after the function above.

}

break;

//////////Record (Used with Memory Group) ///////

case (2) :

{

stored_pin = record_button_state;// change value of stored pin to the memory group stored value

stored_pin = SetLed_NoDump( 6, 6, 7,stored_pin, pin, pin_value);//see case 1 with pins changed

record_button_state = stored_pin;//resets the variable for this group to the current stored pin after the function above.

}

break;

I have had these warnings before and have solved them usually  by supplying missing brackets.

After a long seach on the web and can't find any useful reference to the statement.

Also there must be a list of errors and warnings listed somewhere.

Perhaps someone can point out the cause of the warning and point me to a source of error codes and warnings.

Thank you.

Robin

Link to comment
Share on other sites

oh, I had that soo often too.

This is a real beasty annoying warning. I remember I searched two days the first time I had such a warning; it can be really hard to track that down.

"Conditional flow changed by optimizer" means that SDCC finds something that can be optimized and changes the logic flow. The second line about Evelyn and the modified dog has been inserted by some funny programmer, it's from a song-lyric :)

Looking at the code you provided, I suggest it may be somewhere here:

[tt]

if ((pin >= 1) && (pin <= 5)) 

  group = 1;

  if (pin == 7) 

  group = 2;

        more code

[/tt]

Maybe the problem is with an if coming right after an if; maybe that's confusing...

If it helped in the past, perhaps it helps here, setting brackets, too?

[tt]

if ((pin >= 1) && (pin <= 5))  {

  group = 1;

}

if (pin == 7)  {

  group = 2;

  //  more code

}

[/tt]

If that does not help, I recommend you take a look into the generated asm file, that's located in the "_output/" folder and search for "warning". This gives you a good impression where the error is located exactly. Maybe this helps pointing towards the problem.

And if this does not help either: Can you add the line-numbers or make a screenshot, so we can see the codesnippet with line-numberings as it is in your file?

Good luck!

Best regards,

Michael

Link to comment
Share on other sites

I moved on to other aspects and received other errors due to new code. However I thought that I would see if you were right about brackets on the first if statement.

I commented out the new code that caused errors and compiled again. The was no warning 110.  I then removed the brackets. Still no warning. I am bemused.

It's possible of course, that I have changed something else.

Thanks for your help again.

Robin

Link to comment
Share on other sites

  • 2 years later...
if ((pin >= 1) && (pin <= 5)) 

  group = 1;

  if (pin == 7) 

  group = 2;

maybe the optimizer changes this to

if ((pin >= 1) && (pin <= 5)) 

  group = 1;

else if (pin == 7) 

  group = 2;

or

if (pin >= 1){

if (pin == 7) 

  group = 2;

else if (pin <= 5) 

  group = 1;

}

which would make sense. or it makes a switch construct out of it.

check the sdcc-manual, it tells you something about flow changes. loops like

for($i=0;$i<8;$i++)

  ...

will be reversed by the optimizer (topdown instead of bottom-up) when some

conditions are given. this makes the condition check smaller. you get the

same flow-changed-warning then.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...