Rule A12-1-1 for constructor with "default" keyword

2 Ansichten (letzte 30 Tage)
Trung Tran
Trung Tran am 19 Jun. 2022
Bearbeitet: Anirban am 21 Jun. 2022
Hello Mathwork Support Team,
Currently, I'm fixing rule A12-1-1 for my source code.
The rule A12-1-1 mentions: "Constructors shall explicitly initialize all virtual base classes, all direct non-virtual base classes and all non-static data members."
In my case, I have an example:
class Derived : public Base {
public:
Derived() = default;
}
If I run with Polyspace R2022a, the violation does not exist. But if I run with the older versions (e.g: R2020), the violation rule will occurs with line:
Derived() = default;
So, I want to ask that is this a bug of Polyspace and was it fixed in R2022a?

Antworten (1)

Anirban
Anirban am 21 Jun. 2022
Bearbeitet: Anirban am 21 Jun. 2022
I could not reproduce the rule violation you are seeing with R2020a. For instance, I tried with these examples:
  • Base constructor default-ed:
class Base {
public:
Base() = default;
};
class Derived : public Base {
public:
Derived() = default;
};
  • Base constructor non-default-ed:
class Base {
int a;
public:
Base(): a(1){
}
};
class Derived : public Base {
public:
Derived() = default;
};
It would be great if you can give a fuller reproduction example that shows the R2020a behavior you are seeing. For instance, what is the definition of class Base that is showing this behavior?

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by