Run-time problem when using singleton, inherit and constructor

Hi,
This problem only happens when using singleton, inherit and customized constructor at the same time. It seems that the complier or linker are not working correctly on this situation. Is there any patch on it?

OS: Tested on Windows and Mac.
Arduino IDE: Version 1.6.13.
Arduino 101 Board Manager: Version 1.0.7.
Firmware updated.

Please see the following example. You can comment the customized constructor to eliminate this problem

class test1
{
  public:
    test1(){};  // You can comment this line to eliminate this runtime problem
    virtual void execute();  
};

class test2 :public test1
{
  public:
//    test2(){};  // You can comment this line to eliminate this runtime problem
    void execute(); 
    static test2* instance();
};

test2* test2::instance()
{
  static test2 state;
  return &state;
}

void test2::execute()
{
  Serial.println("hello");
}

test2 *mytest = NULL;

void setup() {
  Serial.begin(115200);
  while(!Serial);
  mytest = test2::instance();  
  Serial.println("test begin");
}

void loop() {
  mytest->execute();
  delay(100);
}

Hi jimaobian,
thanks for reporting, let's keep track of this issue on the core github repo Runtime problem with example · Issue #355 · arduino/ArduinoCore-arc32 · GitHub . Thanks again!

My pleasure Facchinm,
Thanks for your confirmation :slight_smile: