I am receiving the repeatable error shown below. Before I send anyone on a wild goose chase, which is the more likely cause of this error, a stack/heap or some other memory clash or error in my code, or a real compiler error?
A verbose compilation flags no contributory errors that I can see. It only reports compilation and linking of included library code from necessary libraries that were carried over from earlier versions of my sketch that produced no errors.
"In function 'global constructors keyed to 65535_0_GetSolaX_Data_01_3_3.ino.cpp.o':
lto-wrapper.exe: fatal error: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr/bin/avr-gcc returned 1 exit status
Like it says, it is an internal compiler error, NOT a problem with your code. Move your code around, and it will usually go away. If you have functions near the end of the file, move one or more of them closer to the top of the file, or vice-versa. Sometimes completely inane changes to the code will make the error disappear.
The latest version of the IDE MAY have that bug fixed. It also did not exist in older versions (1.8.4 is where I first saw it, I think).
This bug is specific to the 5.4.0-atmel3.6.1-arduino2 version of avr-gcc used by Arduino AVR Boards 1.6.22 and newer. It has been reported here:
Here's the traditional workaround:
Tools > Board > Boards Manager
Wait for downloads to finish.
When you move the mouse pointer over "Arduino AVR Boards", you will see a "Select version" dropdown menu appear. Select "1.6.21".
Click "Install".
Wait for installation to finish.
Click "Close".
If you have File > Preferences > Check for updates on startup checked, the Arduino IDE may occasionally notify you that a new version of Arduino AVR Boards is available, you'll need to refrain from updating back to the new Arduino AVR Boards version, otherwise you'll be back to seeing the segmentation fault error again.
RayLivingston:
The latest version of the IDE MAY have that bug fixed. It also did not exist in older versions (1.8.4 is where I first saw it, I think).
It's not really accurate to say this is a problem with a specific version of the Arduino IDE. The problem is related to using Arduino AVR Boards 1.6.22 or 1.6.23. Yes, the Arduino IDE does come with a version of Arduino AVR Boards bundled (Arduino IDE 1.8.6 is the first IDE version to bundle Arduino AVR Boards 1.6.22). However, Boards Manager allows us to install any version of Arduino AVR Boards with any version of the Arduino IDE, and in fact will prompt you to update to the new version by default. As you discovered, you can get the segmentation fault error with Arduino IDE 1.8.4, even though the Arduino AVR Boards version bundled with that IDE version is 1.6.20, which does not have the segmentation fault issue.
pert:
It's not really accurate to say this is a problem with a specific version of the Arduino IDE. The problem is related to using Arduino AVR Boards 1.6.22 or 1.6.23. Yes, the Arduino IDE does come with a version of Arduino AVR Boards bundled (Arduino IDE 1.8.6 is the first IDE version to bundle Arduino AVR Boards 1.6.22). However, Boards Manager allows us to install any version of Arduino AVR Boards with any version of the Arduino IDE, and in fact will prompt you to update to the new version by default. As you discovered, you can get the segmentation fault error with Arduino IDE 1.8.4, even though the Arduino AVR Boards version bundled with that IDE version is 1.6.20, which does not have the segmentation fault issue.
I understand, but that is a distinction that will be meaningless to anyone who is not familiar with the structure of the Arduino environment. IDE is something they know. The "boards" package is not. Most probably know how to install a newer IDE. Few know how to update a specific component of the IDE, like the Boards package. So, I chose to keep it simple.
Thanks to all who replied. I'm currently using IDE 1.8.9(Windows Store 1.8.21.0) with whichever version of the Arduino Uno it included by default. However my board is quite old so it seems some further digging into the innards of the IDE may be required. However, I'll try the shifting functions trick first. It was creating new functions from segments of otherwise functioning but inelegant code that triggered the error in the first place.
sterretje:
By keeping it simple, you made the info incorrect. The issue did, to my knowledge, not exist in a fresh install of IDE 1.8.4
The issue DOES occur in a fresh install of 1.8.4. That is where I first saw it, nearly two years ago. And I never updated the boards package. I never even used the IDE. I installed from a ZIP file, and used VisualStudio+VisualMicro.
RayLivingston:
The "boards" package is not. Most probably know how to install a newer IDE. Few know how to update a specific component of the IDE, like the Boards package.
I disagree. I think you're still living in the time before Boards Manager when installing a hardware core was something usually done by experienced users who wanted to mess with other chips like ATtiny. However, times have changed. Many very popular boards now require you to use Boards Manager to install a hardware core and this process is quite easy. The automated notifications lead users to do it without even thinking. I think it's important for people to understand the difference between the IDE version and the version of the hardware core they're currently using and I don't think this is too complex a topic. You really don't need any in depth understanding of the Arduino environment to get this. It's all right there in the GUI for your point and click pleasure. It's easier than updating the IDE.
RayLivingston:
I chose to keep it simple.
Your advice would have had them try to update to a newer version of the IDE, when they are already using the newest, then unnecessarily roll back to a very outdated version of the Arduino IDE, which I don't think is even possible when using the Windows App version of the Arduino IDE Slow-Learner has. Even if they had succeeded in installing the old IDE version, they still would need to understand not to update to the newest version of Arduino AVR Boards, which the Arduino IDE will prompt them to do the first time they run the IDE (and every time after that). Then you're right back to that concept of hardware cores that you were trying so hard to hide.
I think using a few clicks in the modern Arduino IDE to fix the problem the right way is way more simple.
RayLivingston:
The issue DOES occur in a fresh install of 1.8.4.
I've never seen a report of the error before Arduino AVR Boards 1.6.22 came out but it's possible you found some extremely rare corner case where a bug in the old compiler version was triggered.
I've provided my stock reply above in the many many reports of this issue here on the forum and on GitHub, and others have echoed the same advice when I didn't get there first, and it has solved the problem every time so your experience is certainly not common.