Warning Message?

Hi Forum,

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\main.cpp: In function 'main':

567:29: warning: iteration 5 invokes undefined behavior [-Waggressive-loop-optimizations]

566:21: note: within this loop

This is the message... I dont... I don't know what this means.

My code have:
5 potentiometers, 2 switches, 1 mix-encoder, 3 switches 3 positions

Please post your full sketch.

If possible, you should always post code directly in the forum thread as text using code tags:

  • Do an Auto Format (Tools > Auto Format[/b) on your code. This will make it easier for you to spot bugs and make it easier for us to read.[/li]
  • - Edit > Copy for Forum*
  • - In a forum reply here, click on the reply field.*
    - Click the </> button on the forum toolbar. This will add the forum’s code tags markup to your reply.
  • - Press “Ctrl + V”. This will paste the sketch between the code tags.*
  • - Move the cursor outside of the code tags before you add any additional text to your reply.*
  • - Repeat the above process if your sketch has multiple tabs.*
  • [/list]*
  • This will make it easy for anyone to look at it, which will increase the likelihood of you getting help.*
  • If the sketch is longer than the 9000 characters maximum allowed by the forum, then it’s OK to add it as an attachment. After clicking the “Reply” button, you will see an “Attachments and other settings” link that will allow you to make the attachment.*
    When your code requires a library that’s not included with the Arduino IDE please post a link (using the chain links icon on the forum toolbar to make it clickable) to where you downloaded that library from or if you installed it using Library Manger (Sketch > Include Library > Manage Libraries in the Arduino IDE or Libraries > Library Manager in the Arduino Web Editor) then say so and state the full name of the library.

barbol_music:
My code have:
5 potentiometers, 2 switches, 1 mix-encoder, 3 switches 3 positions

Do you mean the code you didn't post?

ha ha -.-

I thought you are code wizards, I thought it wasn’t necessary and that it was a standard error.

This is my code …

MCP_-_PROTO_UNO_V2.zip (6.52 KB)

barbol_music:
I thought you are code wizards, I thought it wasn’t necessary and that it was a standard error.

Even if both of those thoughts were true, surely you realise that to fix your code, even a wizard would need to see the code to see what the standard error referred to?

(Unless of course in your world, being a code wizard includes being able to read code through the ether.)

barbol_music:
This is my code ...

So why did you not posted like pert asked you to?

There are good reasons for following the forum rules, in your case what you did was wrong because:-

  1. People don't like down loading zip files because they can contain anything like a virus.
  2. People on mobile devices can not read .zip files or .ino files so they can't help you.

I thought you are code wizards, I thought it wasn't necessary and that it was a standard error.

You thought wrong. All error messages are not caused by only one thing. Without seeing the context only mind reading members will be able to answer your question, and we are short of them at the moment.

I did get my crystal ball out and it told me that your error in in line 27, but it might be out of calibration by now.

You are wizards level 99. You can read codes... and my mind...

The page told me "your code has more than 9000 spells... characters" and as it says above, upload it in Zip ... it does not go with any virus, I suppose.
A strong spell against malware would be useful in that case.

it does not go with any virus,

We only have your word for that and at the moment I don't trust you.
So play by the rules or go away.

barbol_music:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\main.cpp: In function 'main':
567:29: warning: iteration 5 invokes undefined behavior [-Waggressive-loop-optimizations]
566:21: note: within this loop

Show us line 566 and we'll tell you what's wrong.

barbol_music:
The page told me “your code has more than 9000 spells… characters” and as it says above, upload it in Zip … it does not go with any virus, I suppose.

How are we supposed to trust you? Please paste your code in code tags it in code tags </>

LOL :smiley:

barbol_music:
as it says above, upload it in Zip

Just attach the .ino sketch file or files to a reply here directly. Don't put them in a .zip

People here are much more likely to download .ino file attachments than .zip, so you'll be more likely to get help with your problem.

Well it's better if the OP doesn't give anything for download and pastes his code in a reply... :slight_smile:

It is always better to do that. However, the forum has a 9000 character maximum post length limit, so it's not always possible to do so.

@barbol_music already said their code is >9000 characters, so making an attachment is the correct thing to do in this particular case.

Common warning when a for loop is accessing an array and you exceed the bounds of the array.
You defined NUMBER_POTS as 6, but only have 5 elements in the POTS array.

byte NUMBER_POTS = 6;


Pot *POTS[] {&PO1, &PO2, &PO3, &PO4, &PO5};//, &PO6};


void updatePots() {
  for (int i = 0; i < NUMBER_POTS; i = i + 1) {
    byte potmessage = POTS[i]->getValue();
    if (potmessage != 255) MIDI.sendControlChange(POTS[i]->Pcontrol, potmessage, POTS[i]->Pchannel);
    //Serial.println(potmessage);
    // delay(1000);
  }
}

pert:
It is always better to do that. However, the forum has a 9000 character maximum post length limit, so it's not always possible to do so.

@barbol_music already said their code is >9000 characters, so making an attachment is the correct thing to do in this particular case.

Well I learnt something new today then... 8)

Ok, Wizards,
I have 6 pots, and I had to drill my project yet, and that's why the 5 pots of 6.

Thanks a Lot!

My code is now 99%