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

조회 수: 2 (최근 30일)
Trung Tran
Trung Tran 2022년 6월 19일
편집: Anirban 2022년 6월 21일
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?

답변 (1개)

Anirban
Anirban 2022년 6월 21일
편집: Anirban 2022년 6월 21일
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