Hey folks,
  Can you help check which compiler behaves correctly here? To my
untrained mind it seems to be a clang issue but seems too basic to have
been missed unintentionally?

Regards,
Ramneek

x- start -x
class A {};

class B {};

void myfun(A& myexp) {
}

template <typename T>
void mytest(const B &value)
{
   myfun(A(value));
}

template <typename T>
void mytest(const T &value)
{
   myfun(A(value));
}
x-end -x


*output from gcc:*
> gcc --version
gcc (GCC) 4.4.3

> gcc -c ~/test.cpp
Compiles!!

*output from clang:*
> clang++ --version
clang version 3.3 (2545b1d99942080bac4a74cda92c620123d0d6e9)
(2ff97832e593926ea8dbdd5fc5bcf367475638a9)
Target: x86_64-unknown-linux-gnu
Thread model: posix

clang++ ~/test.cpp
test.cpp:12:10: error: no matching conversion for functional-style cast
from 'const B' to 'A'
   myfun(A(value));
         ^~~~~~~
test.cpp:2:7: note: candidate constructor (the implicit copy
constructor) not viable: no known conversion from 'const B' to 'const A'
for 1st argument
class A {};
      ^
test.cpp:2:7: note: candidate constructor (the implicit default
constructor) not viable: requires 0 arguments, but 1 was provided
test.cpp:18:4: error: no matching function for call to 'myfun'
   myfun(A(value));
   ^~~~~
test.cpp:6:6: note: candidate function not viable: expects an l-value
for 1st argument
void myfun(A& myexp) {
     ^
2 errors generated.

This email and any attachments are confidential and may also be privileged. If 
you are not the intended recipient, please delete all copies and notify the 
sender immediately. You may wish to refer to the incorporation details of 
Standard Chartered PLC, Standard Chartered Bank and their subsidiaries at 
http://www.standardchartered.com/en/incorporation-details.html.

_______________________________________________
cfe-users mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users

Reply via email to