[LLVMbugs] [Bug 15634] New: Diagnostic for failed template deduction is insufficient

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Apr 1 11:01:18 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=15634

            Bug ID: 15634
           Summary: Diagnostic for failed template deduction is
                    insufficient
           Product: clang
           Version: 3.2
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: berkus at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Using this sample code
[code]
#include <vector>
#include <boost/array.hpp>

class byte_array
{
    std::vector<char> value;
public:
    template <typename T, size_t N>
    byte_array(const std::array<T, N>& in) : value(in.begin(), in.begin() + N)
{}
};

int main()
{
   boost::array<unsigned char, 32> arr;
   byte_array data(arr);
}
[/code]
(see http://liveworkspace.org/code/2uLY7q$4)

Clang's error diagnostic is quite not sufficient to spot and fix the error:

[irrelevant text skipped]
source.cpp:9:5: note: candidate template ignored: failed template argument
deduction
    byte_array(const std::array<T, N>& in) : value(in.begin(), in.begin() + N)
{}
    ^
1 error generated.

Gcc 4.8.0 on the other hand provides much more helpful text, which lets fix the
error on the spot (even gcc 4.7.2 nails it):

source.cpp:9:5: note:   template argument deduction/substitution failed:
source.cpp:15:23: note:   'boost::array<unsigned char, 32ul>' is not derived
from 'const std::array<_Tp, _Nm>'
    byte_array data(arr);
                       ^

It is possible to test the output of both the compilers with provided test code
on the liveworkspace website directly.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130401/3ecb351f/attachment.html>


More information about the llvm-bugs mailing list