Breathing white LED with a Serial.print in object constructor

Continuing the discussion from Call of Serial.print before Serial.begin gives a white breathing LED:

This particular bug has not been entirely fixed. The following code gives you a breathing white LED

#pragma SPARK_NO_PREPROCESSOR
#include "application.h"

class A {

    public:
    
    A()  {  Serial.begin(9600); Serial.print("die");  }
    
};


A anA;

void setup()
{
    // Doing Serial.print right here before Serial.begin does not kill the core.
    //Serial.begin(9600);
}

void loop() { }

If the Serial.begin is in setup() instead of the constructor, it still causes the breathing white LED.

Doing a Serial.print in setup() right before the Serial.being does not cause the breathing white led, so that bit was fixed.

@dalospa, maybe this known issue and the suggested workaround does aply here too.

And maybe @BDub wants to have a look too, since he stated in the thread above that this issue should have been killed already :wink:

I solved the problem by doing the object creation in the setup(), after the call to Serial.begin(), which, in retrospect, seems the obviously sensible way of doing it. However, this did indicate a possible underlying problem, or at least code that might be a bit more defensive. I did kill off some hours tracking this down because the references to the breathing white problem pointed other directions.