title: Strange behavior with gcc on MCU, code skips lines if no breakpoint is inserted
body: <p>I have a project using FreeRTOS on a SoC by Microsemi called SmartFusion2.</p>
  <p>Here's the part that's not executed.</p>
  <pre><code>struct buffer{
      uint8_t version;
      //other members
  };
  
  i2c_read(&amp;i2c_handler, DATA_ID, (uint8_t*)&amp;buffer, DATA_LEN);
  
  if(buffer.version != 0x05){
  
      DEBUG_PRINT(&quot;Copying done. Running the program\n&quot;);
      //some i2c transfer here
      vTaskDelay(500);
      status = i2c_read(&amp;i2c_handler, DATA_ID, (uint8_t*)&amp;buffer, DATA_LEN);
  
      if(status &gt; 0){
              vTaskDelay(10000);
              //some more i2c operation here
              if(buffer.version != 0x05){
                  DEBUG_PRINT(&quot;Started in bootloader mode\n&quot;);
              } else {
                  DEBUG_PRINT(&quot;Success\n&quot;);
              }
      } else {
         DEBUG_PRINT(&quot;Failed connecting\n&quot;);
      }
  } else {
      DEBUG_PRINT(&quot;OK\n&quot;);
  }
  </code></pre>
  <p>The output is only this.</p>
  <blockquote>
  <p>Copying done. Running the program</p>
  </blockquote>
  <p>I am definitely sure it is not just a printing/UART problem because it skips over the 10 second delay as well and continues executing the next tasks.</p>
  <p>However, when I insert a breakpoint on the line that prints it and step over, one of the next DEBUG_PRINT statements is executed normally (in this case, &quot;Started in bootloader mode&quot;).</p>
  <p>Could this have something to do with optimization? I use -Os. I don't think adding a breakpoint would change anything in that case though. Any ideas what could be the case here?</p>