[cfe-dev] Why a formalparameter object can not be treated as object reference

王长城 200005275 at 163.com
Tue Oct 30 19:20:48 PDT 2012


 Hi to all:
I have a test case which work well on VS2012,but i got an error when i compile it with clang++.
the test case is:
#include <iostream>

class AA {
 public:
  AA(int i):ii(i){}
  ~AA(){}
 public: 
  int ii;
};

int foo( AA& a) {
  return a.ii;
}

int main() {
  AA aa(1);
  int rec1 = foo(aa);
  int rec2 = foo(AA(1));
  std::cout << rec1 << '\n' << rec2 << '\n';
  return rec1 == rec2? 0 : 1;
}

the error is:
reference_test.cpp:18:14: error: no matching function for call to 'foo'
  int rec2 = foo(AA(1));

Is it a bug of clang or not? 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121031/8d8a95fb/attachment.html>


More information about the cfe-dev mailing list