Unsolved Default special member binary compatibility
-
Hi
if I have a class:
header:class Foo : public QObject{ Q_OBJECT public: Foo(QObject* parent = nullptr); ~Foo(); };
Source
Foo::Foo(QObject* parent = nullptr) :QObject(parent){} Foo::~Foo() = default;
Can I change the destructor to
Foo::~Foo(){ bar(); }
without breaking binary compatibility?
-
Gut feeling says "no binary compatibility break" but I don't trust it too much. I guess easiest would be to bake Foo into a library, do the change and check if some code using that library will still work after swapping the lib.
-
Why on earth would it break? Binary compatibility is about interfaces, not implementation, and interface didn't change
-
@Konstantin-Tokarev said in Default special member binary compatibility:
Why on earth would it break?
If you don't have a destructor at all (i.e. you leave it implicitly default) and you add it later then you binary compatibility is broken. My question is, is the result different if I make it explicitly default?
-
@VRonin said in Default special member binary compatibility:
If you don't have a destructor at all (i.e. you leave it implicitly default) and you add it later then you binary compatibility is broken
That's wrong. Compatibility is broken if you add virtual destructor to the class which didn't have one. However, in your case implicit destructor is already virtual, because Foo inherits QObject
-
@Konstantin-Tokarev said in Default special member binary compatibility:
That's wrong
Ok, I was told the opposite and I have the maximum respect for your and David's opinion so I don't know who to believe anymore :(