Open llvmbot opened 11 years ago
Using clang3.8, bug_clang_template_deduction.cpp compiles for me:
make showbug /home/evansl/dwnlds/llvm/3.8/prebuilt/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04/bin/clang++ -c -O0 -stdlib=libc++ -std=c++14 -ftemplate-backtrace-limit=0 -fdiagnostics-show-template-tree -fno-elide-type -fmacro-backtrace-limit=0 --version clang version 3.8.0 (tags/RELEASE_380/final) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /home/evansl/dwnlds/llvm/3.8/prebuilt/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04/bin uname -a Linux lje-OptiPlex-9020 4.4.0-57-generic #78-Ubuntu SMP Fri Dec 9 23:50:32 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux /home/evansl/dwnlds/llvm/3.8/prebuilt/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04/bin/clang++ -c -O0 -stdlib=libc++ -std=c++14 -ftemplate-backtrace-limit=0 -fdiagnostics-show-template-tree -fno-elide-type -fmacro-backtrace-limit=0 -c bug_clang_template_deduction.cpp
Compilation finished at Sun Jan 8 01:52:59
So, apparently, the problem Martin was having was different than my problem.
I guess I should open separate bug report?
-regards, Larry
showbug.imk output This output shows 3 compile runs with varying values the the macros. The last run should compile OK; however, it produces the incorrect error message about out-of-line definition not matching anything in the template class.
makefile snippet Use this makefile snippet (with your definition of COMPILE.HOW) to reproduce the showbug.out attachment.
Thanks, interesting testcase. I expect the issue is that when parsing the declaration of the template, we create a simple multiplication node (because unqualified lookup finds no 'operator*') for the dependent multiplication expression, but when parsing the definition, we create an overloaded operator expression to store the result of unresolved name lookup -- and we (incorrectly, as far as I can tell) believe this difference makes the function template signature different.
Extended Description
In the attached reduced testcase, clang incorrectly gives me the compile error:
bug_clang_template_deduction.cpp:46:18: error: out-of-line definition of 'bar' does not match any declaration in 'derived' void derived::bar(Matrix<baseclass::n*baseclass::n>& F_x)
clang fails because of the combination of the following four aspects:
Removing any of these four aspects makes the code compile. The code is valid afaict.
Tested on clang 3.2 and trunk: clang version 3.3 (trunk 176804) Target: x86_64-unknown-linux-gnu Thread model: posix