Possible compiler bug when using -Os #2062
-
Hi there, I started playing with arduino-pico some days ago. To reproduce use the following code; #include <Arduino.h>
class SimpleFIFO
{
public:
SimpleFIFO() { head = 0; tail = 0; }
public:
bool isEmpty() { return( head == tail ); }
uint16_t head{};
uint16_t tail{};
};
static SimpleFIFO fifo;
void setup() {
delay( 5000 );
Serial.begin( 115200 );
}
void loop() {
Serial.print( F("isEmpty = ") ); Serial.println( fifo.isEmpty() );
while( fifo.isEmpty() ); // -> while( true ) !!!
// should *never* come here
Serial.println( F("NO WAY ! ! !") );
} Obviously the output should be isEmpty = 1 But on my machine the output is (and of course repeating): isEmpty = 1
NO WAY ! ! ! That problem haunted me until I used an Arduino Zero and suddenly everything worked as expected. Any ideas? Windows 11 64 bit Stay safe, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
That's pretty neat (in a bad way) and seems like a GCC ARM-specific bug you might want to post on the GNU mailing list/bugzilla (GCC 12.3.0 is what we run). If you use GDB shows the code in
While in
|
Beta Was this translation helpful? Give feedback.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114421