Weird compiler error: unable to find a register to spill in class 'NO_REGS'

When I try to compile some code for the Arduino I get a weird error that I do not unbderstand, see below. It happens at a statement where I use a sscanf as follows:

sscanf (buffer, TX_FORMAT_1, &lat, &lng, &alt, &ap_groundspeed, &ap_heading);

When I do a sscanf for only one variable the code compiles well. I do not know what this error is and how to prevent it. Workarounds are appreciated as well.

Edit: I forgot to mention that the compiler version is 1.6.9. The problem is solved when "upgrading" to version 1.0.6.

Error message:

Arduino: 1.6.9 (Windows 7), TD: 1.29, Board: "Arduino/Genuino Micro"

C:\Users\arnold\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\cores\arduino\main.cpp: In function 'main':

C:\Users\arnold\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\cores\arduino\main.cpp:51:1: error: unable to find a register to spill in class 'NO_REGS'



C:\Users\arnold\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\cores\arduino\main.cpp:51:1: error: this is the insn:

(insn 607 604 610 45 (set (mem:QI (post_dec:HI (reg/f:HI 32 __SP_L__)) [0  S1 A8])

        (subreg:QI (reg/f:HI 658) 1)) sketch\coordinates.cpp:23 1 {pushqi1}

     (expr_list:REG_ARGS_SIZE (const_int 1 [0x1])


C:\Users\arnold\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\cores\arduino\main.cpp:51: confused by earlier errors, bailing out

lto-wrapper: C:\Users\arnold\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-gcc returned 1 exit status

c:/users/arnold/appdata/local/arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ld.exe: lto-wrapper failed

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino/Genuino Micro.

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


This report would have more information with

“Show verbose output during compilation”
option enabled in File → Preferences.

Then why don’t you enable verbose output and show us?

Workarounds are appreciated as well.

I don’t know how your input string is formatted, but if it uses a fixed pattern and/or separator characters, you might solve it by using strtok, strstr or other C++ string functions, and then use atoi, atof or atol to convert those pieces of string to an int, float or long respectively.
(Given that you use an array of chars as string, not an Arduino String.)

There is nothing wrong with using sscanf(). What is most likely wrong is that you are not using it correctly.

We can not tell based on one line of code.

You do have quotes around the definition of TX_FORMAT_1, right?

#define TX_FORMAT_1 "%s %*s %d"

and not this:

#define TX_FORMAT_1 %s %*s %d

But it's difficult to tell what's wrong without knowing the full code.

You could try temporarily back-pedalling to Arduino AVR Boards V1.6.11 and see if that fixes it.

Alternatively, I'm using IDE V1.6.9 with arduino AVR Boards V1.6.11, so if you post your code, (or attach it if it's too large), I'll check and see if it compiles for me.

There's been an on-and-off issue that produces this error for some time, related I think to different combinations of the IDE and Arduino AVR boards.