<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><span style="background-color: rgba(255, 255, 255, 0);">The GCC C++ status page (<a href="https://gcc.gnu.org/projects/cxx-status.html">https://gcc.gnu.org/projects/cxx-status.html</a>) shows that class template argument deduction wasn’t implemented until GCC-7.</span><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">However Clang’s status page also reports it as implemented (in SVN builds), but Clang built from SVN trunk rejects that code.</span></div><div><br>On 15 Aug 2017, at 11:53, Dimitry Andric wrote:<br><br></div><blockquote type="cite"><div><span>Hm, it appears to depend on the gcc version:</span><br><span></span><br><span>$ g++6 -std=c++17 test.cpp</span><br><span>test.cpp: In function 'int main()':</span><br><span>test.cpp:8:9: error: missing template arguments before 'b'</span><br><span> Base b(d);</span><br><span> ^</span><br><span></span><br><span>However, gcc 7.1.1 does accept it. So maybe this is something very new?</span><br><span></span><br><span>-Dimitry</span><br><span></span><br><blockquote type="cite"><span>On 15 Aug 2017, at 12:46, Hamza Sood <<a href="mailto:hamza_sood@me.com">hamza_sood@me.com</a>> wrote:</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>Sorry, I should’ve been more clear. I’m talking about C++17 class template argument deduction.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>If you pass “-std=c++17” to GCC, then it compiles the code fine. However Clang still rejects it.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>(Sending again because I forgot to reply all)</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>On 15 Aug 2017, at 11:40, Dimitry Andric wrote:</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>On 15 Aug 2017, at 12:04, Hamza Sood via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>template<typename T></span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>class Base { };</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>class Derived: public Base<int> { };</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>int main() {</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Derived d;</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Base b(d);</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>return 0;</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>}</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Clang rejects that code, saying it can’t deduce the template parameters for Base.</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>However I think that code is valid; it’s accepted by GCC.</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Not here, with gcc 6.4.0:</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>$ g++ -c test.cpp</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>test.cpp: In function 'int main()':</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>test.cpp:8:9: error: missing template arguments before 'b'</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span> Base b(d);</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span> ^</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>The declaration should use Base<int> instead.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Is this a Clang bug?</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>No, though clang's error message is substantially more confusing, in my opinion:</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>$ clang++ -c test.cpp</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>test.cpp:8:4: error: unknown type name 'Base'; did you mean 'Derived::Base'?</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Base b(d);</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>^~~~</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Derived::Base</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>test.cpp:2:7: note: 'Derived::Base' declared here</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>class Base { };</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span> ^</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>It should give a similar suggestion as gcc does.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-Dimitry</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><span></span><br></div></blockquote></body></html>