Arduino IDE Compilation Error Due to Incorrect Directory Name

Excellent work on troubleshooting!

Yes, that is the problem. It is a bug/deficiency in GCC (avr-g++ is a part of avr-gcc, which is a variant of GCC for the AVR microcontrollers):

The bug has been fixed, but the fix is in GCC 13, while the "Arduino AVR Boards" platform and most other Arduino boards platforms are using a significantly older version of GCC which doesn't have the fix.

Yes, and I think this will be the most simple workaround. I'll provide instructions you can follow to do that:

  1. Select File > Quit from the Arduino IDE menus if it is running.
    All IDE windows will close.
  2. Open the file at the following path in any text editor:
    C:\Users\<username>\.arduinoIDE\arduino-cli.yaml
    
    (where <username> is your Windows username)
  3. Add the following content to the arduino-cli.yaml file (or replace the existing content if equivalent content is already present in the file):
    build_cache:
      path: <build cache folder path>
    directories:
        builtin:
            libraries: <built-in libraries folder path>
        data: <data folder path>
        user: <sketchbook folder path>
    
  4. Replace the <build cache folder path> placeholder with the path to the folder under which you want Arduino to store the cached data for compiling sketches.
    :warning: Arduino IDE periodically deletes the contents of this folder (the files stored under it are only cached there for the sake of efficiency, and it can always regenerate the files on demand), so you should not use this folder to store any valuable files.
  5. Replace the <built-in libraries folder path> placeholder with the path to the folder under which you want Arduino to store some fundamental "built-in" Arduino libraries.
  6. Replace the <data folder path> placeholder with the path to the folder under which you want Arduino to store the boards platforms you install via Boards Manager, as well as some other data files.
  7. Replace the <sketchbook folder path> placeholder with the path you want to use as the Arduino sketchbook (the folder under Arduino IDE stores libraries you install via Library Manager and "Add .ZIP Library...", as well as a convenient location to save your sketches).
    Unlike the other paths, you can also configure this one via Arduino IDE's preferences GUI. I thought I should include it in these instructions just to be comprehensive.
  8. Save the file.
  9. Move the files from this folder on your hard drive:
    C:\Users\Samir Budimčić\AppData\Local\Arduino15\libraries
    
    to the folder you configured in step (5) above ("<built-in libraries folder path>").
  10. Move the files from this folder on your hard drive:
    C:\Users\Samir Budimčić\AppData\Local\Arduino15
    
    to the folder you configured in step (6) above ("<data folder path>").
  11. If you configured a different folder in step (7) above ("<sketchbook folder path>"), move the files from the previous sketchbook folder location to the new one.
  12. Start Arduino IDE.

Now try compiling or uploading your sketch again. Hopefully this time it will be successful.

Alternative Workaround

In case it will be of use to you (or anyone else suffering from this problem who finds the forum topic while searching for a solution), I'll mention that I did find an alternative workaround that allows you to use the paths that contain non-ASCII characters. It requires changing an "experimental" Windows setting, which affects the Windows operating system and all applications, so it is possible it could affect the stability of Windows or compatibility with other applications. So it is definitely something that should be done with caution, if at all:

  1. Right click the Windows "Start" button.
    A context menu will open.
  2. Select "Settings" from the menu.
    Windows Settings will open.
  3. Select "Time & language" from the navigation panel on the left side of the Settings window.
    The "Time & language" settings will open in the right panel of the window.
  4. Select "Language & region" from the right panel of the Settings window.
    The "Time & language > Language & region" settings will open in the right panel of the window.
  5. Select "Administrative language settings" from the right panel of the Settings window.
    The "Region" dialog will open.
  6. Click the "Change system locale" button in the "Region" dialog.
    The "Region Settings" dialog will open.
  7. Check the checkbox next to "Beta: Use Unicode UTF-8 for worldwide language support".
  8. Click the "OK" button.
    The "Change System Locale" dialog will open, notifying you that you must restart your computer before the setting change will take effect.
  9. Save any unsaved work in open applications.
  10. Click the "Restart now" button in the "Change System Locale" dialog.
    Your computer will restart.

After doing that, you should be able to compile without encountering the unexpected error.