No. An implicitly defined trivial destructor is by definition trivial. The difference between a declaration and a thingy definition is that in order for the compiler to even see that the destructor is available, there must always be an declaration. Therefore, if you do not provide it, it will implicitly provide it.
But now it will also determine one, if necessary (if an object of this type of class is destroyed). In any case, he must do something: he needs to call the destructors of all its members and base classes. A simple example illustrating the effect of implicitly defining a destructor:
struct a { private: ~a(); }; struct bug {
As soon as you try to create a local object with an error, the compiler will signal an error, because it gives a definition of the destructor for the error, which tries to call an inaccessible destructor.
Now I think that the triviality of destructors / constructors is mainly used to limit the restrictions on your program. For example, objects that have non-trivial versions cannot be placed in unions. On the other hand, you can delete an object with an incomplete type if it has a trivial destructor. Note: if your program cannot decide if a trivial destructor was really defined, the compiler may omit its definition. This is the so-called as-if rule. The compiler should behave like this: if it is compatible with the standard, optimization does not matter until they change the value of the program.
source share