<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Apr 24, 2013, at 9:22 AM, Ramneek Handa <<a href="mailto:ramneekhanda@gmail.com">ramneekhanda@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Hey folks,<br>Can you help check which compiler behaves correctly here? To my<br>untrained mind it seems to be a clang issue but seems too basic to have<br>been missed unintentionally?<br></div></blockquote><div><br></div><div>Both behaviors are "correct", in the sense that a compiler is allowed to diagnose templates that have no valid instantiations (but is not required to). Clang tends to be more picky about such things. See</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">  </span><a href="http://clang.llvm.org/compatibility.html#bad_templates">http://clang.llvm.org/compatibility.html#bad_templates</a><br></div><div><br></div></div><div><span class="Apple-tab-span" style="white-space:pre">     </span>- Doug</div><div><br><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Regards,<br>Ramneek<br><br>x- start -x<br>class A {};<br><br>class B {};<br><br>void myfun(A& myexp) {<br>}<br><br>template <typename T><br>void mytest(const B &value)<br>{<br>myfun(A(value));<br>}<br><br>template <typename T><br>void mytest(const T &value)<br>{<br>myfun(A(value));<br>}<br>x-end -x<br><br><br>*output from gcc:*<br><blockquote type="cite">gcc --versiongcc (GCC) 4.4.3<br></blockquote><br><blockquote type="cite">gcc -c ~/test.cppCompiles!!<br></blockquote><br>*output from clang:*<br><blockquote type="cite">clang++ --versionclang version 3.3 (2545b1d99942080bac4a74cda92c620123d0d6e9)<br></blockquote>(2ff97832e593926ea8dbdd5fc5bcf367475638a9)<br>Target: x86_64-unknown-linux-gnu<br>Thread model: posix<br><br>clang++ ~/test.cpp<br>test.cpp:12:10: error: no matching conversion for functional-style cast<br>from 'const B' to 'A'<br>myfun(A(value));<br>^~~~~~~<br>test.cpp:2:7: note: candidate constructor (the implicit copy<br>constructor) not viable: no known conversion from 'const B' to 'const A'<br>for 1st argument<br>class A {};<br>^<br>test.cpp:2:7: note: candidate constructor (the implicit default<br>constructor) not viable: requires 0 arguments, but 1 was provided<br>test.cpp:18:4: error: no matching function for call to 'myfun'<br>myfun(A(value));<br>^~~~~<br>test.cpp:6:6: note: candidate function not viable: expects an l-value<br>for 1st argument<br>void myfun(A& myexp) {<br>^<br>2 errors generated.<br>-RH<br><br><br>_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a></div></blockquote></div><br></body></html>