baloghadamsoftware added a comment.

I am not sure whether we should copy with such ugly things as overloaded member 
access operators with side effects, but they can also cause troubles using this 
fix:

  #include <iostream>
  
  using std::cout;
  using std::endl;
  
  struct C {
    static int N;
    int n = 0;
  };
  
  int C::N = 0;
  
  struct Cptr {
    C* c;
  
    explicit Cptr(C *cc): c(cc) {}
  
    C* operator->() {
      ++c->n;
      return c;
    }
  };
  
  int main() {
    Cptr cp(new C);
    cout<<"n: "<<cp->n<<endl;
    cp->N = 10;
    cout<<"n: "<<cp->n<<endl;
  }

Output:

  n: 1
  n: 3

After the fix, the output chanes to:

  n: 1
  n: 2


Repository:
  rL LLVM

https://reviews.llvm.org/D35937



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to