arduino / arduino/ArduinoCore-arc32
Runtime problem with example
- Dominant language
- C
- Stars
- 330
- Forks
- 281
- PR merge metrics
- No merged PRs in 30d
Description
Hi. When we try to use singleton, inherit and customized constructor at the same time this problem will occur. Please see the following example.
You can comment the customized constructor to eliminate this problem
OS: Tested on Windows and Mac.
Arduino IDE: Version 1.6.13.
Arduino 101 Board Manager: Version 1.0.7.
Firmware updated.
```
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);
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the supplied sketch on the Arduino 101 using Arduino IDE 1.6.13, starting with setup() and test2::instance(). Compare the behavior with the customized constructors commented out as described; done means this singleton, inheritance, and customized-constructor combination no longer causes the reported runtime failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- arduino, cpp
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100