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

2 visualizzazioni (ultimi 30 giorni)
Trung Tran
Trung Tran il 19 Giu 2022
Modificato: Anirban il 21 Giu 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?

Risposte (1)

Anirban
Anirban il 21 Giu 2022
Modificato: Anirban il 21 Giu 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