title: Overloading function handling char and String
body: <p>I'm making a function to handle a message, then print the  message using Serial.println().  I have it working, but ran into an issue I can't explain. The first sample code below works, the second (swapping the order of my function declaration) will compile and load, but causes the Teensy 4.1 to crash. I'm using PlatformIO on VSCode.</p>
  <p>Can anyone tell me what is wrong with the second code, and why it will compile without error, but not run?</p>
  <p>This works:</p>
  <pre><code>#include &lt;Arduino.h&gt;
  
  void LogMsg(const char *msg){
    Serial.println(msg);
  }
  void LogMsg(String s){ LogMsg(s.c_str()); }
  
  void setup() {
    // put your setup code here, to run once:
    Serial.begin(115200);
    Serial.println(&quot;reset&quot;);
  }
  
  void loop() {
    // put your main code here, to run repeatedly:
  
    String str3 = &quot;testing string cat &quot;;
    uint32_t var = 12345;
    LogMsg(str3 + var);
  
    delay(500);
  }
  </code></pre>
  <p>This compiles, loads, but crashes, causing continuous resets:</p>
  <pre><code>#include &lt;Arduino.h&gt;
  
  void LogMsg(String s){ LogMsg(s.c_str()); }   // &lt;-- swapped order
  void LogMsg(const char *msg){                 // &lt;-- swapped order
    Serial.println(msg);
  }
  
  void setup() {
    // put your setup code here, to run once:
    Serial.begin(115200);
    Serial.println(&quot;reset&quot;);
  }
  
  void loop() {
    // put your main code here, to run repeatedly:
  
    String str3 = &quot;testing string cat &quot;;
    uint32_t var = 12345;
    LogMsg(str3 + var);
  
    delay(500);
  }
  </code></pre>
  <p>Edit: The definition of <code>void LogMsg(String s)</code> was changed to reflect error in original and the simplification suggested by @hcheung.  Behavior remains the same.  The first instance works, the second crashes.</p>