title: Can't explain compiler's behavior
body: <p>Consider this simple code:</p>
  
  <pre><code>class A {
  public:
      int value;
      A(int value) { this-&gt;value = value; }
      ~A() { printf("destroying %d\n", value); }
      A operator ++() { return A(value + 1); }
  };
  
  int main() {
      A a(1);
      printf("before increment: %d\n", a.value);
      a = ++a;
      printf("after increment: %d\n", a.value);
      return 0;
  }
  </code></pre>
  
  <p>This outputs:</p>
  
  <blockquote>
    <p>before increment: 1<br>
    destroying 2<br>
    after increment: 2<br>
    destroying 2<br></p>
  </blockquote>
  
  <p>Why is the value of <code>a</code> 1 more before being destroyed? </p>