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

王长城 200005275 at 163.com
Tue Oct 30 20:35:10 PDT 2012


Thanks for your help,but why my test case can compile and run well on VS2012, they do not fix this bug still?
在 2012-10-31 10:54:22,"Richard Smith" <richard at metafoo.co.uk> 写道:
>On Tue, Oct 30, 2012 at 7:20 PM, 王长城 <200005275 at 163.com> wrote:
>>  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?
>
>It's an MSVC bug.
>
>http://msdn.microsoft.com/en-us/library/cfbk5ddc(v=vs.80).aspx





More information about the cfe-dev mailing list