Coding issue please help

My son is having issues with his coding for his CNC machine. Please help us figure out how to fix it:

Arduino: 1.8.13 (Mac OS X), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

sketch/src/module/settings.cpp: In function 'report':
sketch/src/module/settings.cpp:3731:11: warning: iteration 4 invokes undefined behavior [-Waggressive-loop-optimizations]
SERIAL_CHAR(axis_codes[q]);
^
sketch/src/module/settings.cpp:3729:9: note: within this loop
LOOP_L_N(q, MOTOR_CURRENT_COUNT) {
^
Sketch uses 125792 bytes (49%) of program storage space. Maximum is 253952 bytes.
Global variables use 4916 bytes (60%) of dynamic memory, leaving 3276 bytes for local variables. Maximum is 8192 bytes.
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
An error occurred while uploading the sketch

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

hard to suggest not having the source code to inspect

suggest to cut down the program to a bare minimum, and then start adding code until error is found
good luck

Not a Mac user so no idea.

traja47:
hard to suggest not having the source code to inspect

Although there is a code issue, it's not the cause of the upload error.

sketch/src/module/settings.cpp:3731:11: warning: iteration 4 invokes undefined behavior [-Waggressive-loop-optimizations]
           SERIAL_CHAR(axis_codes[q]);

That looks like an array bounds issue.
It isn't causing the upload issue, but it should be looked-at.

Too many characters so this forum won't let me paste it here so I put the code into a pdf document. I've attached it to this message.

Marlin Firmware Code.pdf (198 KB)

Why a PDF? :o

I tried a word doc and it wouldn't attach. Let's try a text doc and see if that works.

Marlin Firmware Code.txt (87.7 KB)

Is that code "settings.cpp" ?
It doesn't appear to contain " SERIAL_CHAR(axis_codes[q]);"

TheMemberFormerlyKnownAsAWOL:
Why a PDF? :o

Do you have another suggestion on how I would get all that code accessible so you guys can see it to help us figure out what's wrong?

TheMemberFormerlyKnownAsAWOL:
Is that code "settings.cpp" ?
It doesn't appear to contain " SERIAL_CHAR(axis_codes[q]);"

This is the code that gets uploaded to the CNC machine. This is what he ordered: LowRider v3 Hardware kit – V1 Engineering Inc
He was suppose to be able to just upload the code but he's getting that error message. I know minimal coding and he's trying to teach himself but he got stuck.

TheMemberFormerlyKnownAsAWOL:
Is that code "settings.cpp" ?
It doesn't appear to contain " SERIAL_CHAR(axis_codes[q]);"

Where would I insert: " SERIAL_CHAR(axis_codes[q]);" ?
And do we need to add any additional parameters to it?

bleeglaser:
Where would I insert: " SERIAL_CHAR(axis_codes[q]);" ?
And do we need to add any additional parameters to it?

No, that code is already in settings.cpp, according to your first post.
You appear no to have posted settings.cpp.
The compiler is highlighting that something may be wrong with that code, but that isn't causing the real problem, which is that the code won't upload.