title: What is the difference between a trivial ctor (or dtor) and a user defined empty ctor (or dtor)
body: <p>The C++ standard defines some very specific behaviors when a class has a trivial constructor and/or a trivial destructor.</p>
  <p>As an example, as per §3.8/1 of the standard:</p>
  <blockquote>
  <p>The lifetime of an object of type <code>T</code> ends when:</p>
  <p>— if <code>T</code> is a class type with a non-trivial destructor (12.4), the destructor call starts, or</p>
  <p>— the storage which the object occupies is reused or released.</p>
  </blockquote>
  <p>So,</p>
  <ul>
  <li>if an object is not trivialy destructible, any attempt to access members of the object after the destructor is called is UB.</li>
  <li>if an object is trivialy destructible, attempt to access members of the object after the destructor is called is safe and not UB.</li>
  </ul>
  <p>Although this example may not be the best one, it shows that the difference in behavior maybe crucial (UB/non-UB) whether an object is trivialy destructible or not.</p>
  <p>§12.4/3 of the Standard states that (to sumerize) a destructor of a class <code>T</code> is trivial if it is <strong>implicitely defined</strong>, not virtual, and if all base classes and members of class <code>T</code> are trivially destructible.</p>
  <p>In my (modest) experience, I never saw any difference, in terms of code generated by the compiler, between :</p>
  <ul>
  <li>a class with a trivial default ctor and/or a trivial dtor, and</li>
  <li>a class with a <strong>user defined empty</strong> ctor and/or a non-virtual <strong>user defined empty</strong> dtor (as long as the class, its base classes and members classes also have non-virtual dtor user defined empty or trivial)</li>
  </ul>
  <p>So, my questions are:</p>
  <ul>
  <li>In what way a user defined empty ctor/dtor can or cannot be considered as a trivial-like ctor/dtor regarding compiler code generation, optimizations, trade-offs, ...</li>
  <li>Same question with user defined non-empty ctor/dtor; what rules should follow a code implemented in ctor/dtor to consider them as trivial-like.</li>
  </ul>
  <p>My question is not related to standard (please, do not answer the standard states what is a trivial ctor/dtor, so user defined ctor/dtor is not) but to the way compilers deal with user defined ctor/dtor and in what way the behavior of a compiled code may change (or not) compared to trivial ctor/dtor.</p>