Closed danlu01 closed 5 years ago
Please put your code into "```" brackets so it can be read better. The simple solution to this is: Just DONT us floats on AVR. It just makes no sense at all. also it is important to know what board you used.
I'm compiling for Mega2560 but get same error if compile for UNO as well. To me it's a compiler optimization error with pointers.
Yep, it's a gcc bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60040). If you feel brave you could test if gcc 5.1.0 solves it following these instructions (https://github.com/arduino/Arduino/issues/660#issuecomment-120433193)
I just tried 5.1, still broken. I've reduced this testcase to work outside of Arduino and added it to the gcc bug report.
@danlu01, it seems that enabling O2 (more optimizations) prevents this issue from occurring with your code. As a workaround, you could add this near the top of your sketch, to compile just that one function with O2 optimizations:
float getSlope(float history[]) __attribute__((__optimize__("O2")));
(just tried, works for me)
Thanks for the workaround.. run into another compiler bug. I'll create another ticket.
All;
I have the same problem and it doesn't involve floats (though I use floats elsewhere).
As I uncomment more of my class, the constructor, _AD_Synth::AD_Synth(ThreeWire& comport), I get the "register to spill" message. I tried the attribute workaround with no success.
BTW: When I wrote it all as C-based (not a class) code, the large struct worked just peachy, with essentially the same function as the method.
Sorry about the length of the code and especially the attributes -- but the ADF4351 synthesizer is a complicated device.
Regards, Dan synth.ino.txt AD_synth.cpp.txt AD_Synth.h.txt ThreeWire.cpp.txt ThreeWire.h.txt
I was having the same issue and I simply resolved it. All what I did is downloading the LAST UPDATE (4 October 2016 14:52:59 GMT) for Arduino software in the software download page (Arduino software hourly builds) at the bottom left of the page. The sketch was successfully compiled. HOPE this helps ! https://www.arduino.cc/en/Main/Software
I just tried an hourly build "21 October 2016 16:13:52 GMT" - which came with 'avr-gcc (GCC) 4.9.2' but it didn't solve the problem for me.
error: unable to find a register to spill in class 'POINTER_REGS'
Looks like I just got the same problem with Arduino 1.6.11
This line compiles Ok in multiple places of sketch:
sprintf(msg_payload, "%s is ON", module_config.client_name);
but in one place of the sketch this line:
sprintf(msg_payload, "%s connected", module_config.client_name);
returns an error:
...\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.14\cores\arduino\main.cpp:51:1: error: unable to find a register to spill in class 'NO_REGS'
...
(subreg:QI (reg/f:HI 458) 1)) ...\GITprojects\Sourceforge\home-controller-code\Arduino\AERCM\AERCM.ino:185 1 {pushqi1}
(expr_list:REG_ARGS_SIZE (const_int 1 [0x1])
(nil)))
With just one parameter a compilation is Ok:
sprintf(msg_payload, "%s", module_config.client_name);
According to the GCC bug, this will be fixed in GCC 7.0. They might backport the fix to earlier versions, if so I think it should be mentioned in the bug report as well. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60040
Hello All, I am still getting the PONITER_REGS error in the UNO board. I am using 1.8.5 IDE!
So am I. Used to work, I don't remember what was the IDE version (had to reinstall everything after hdd crash)
Looks like it's fixed by avr core version 1.8.1 (using toolchain 7.4.0)
I upgraded from Arduino IDE 1.0.6 to 1.6.5 and now my sketch have compile error:
unable to find a register to spill in class 'POINTER_REGS'
I've narrow it down to a function (I've modified it to try to understand the compile error). Odd thing is if I remove any of the 4 line of code in the for loop, then it compiles ok. Here's the test sketch with this issue: