[LLVMbugs] [Bug 11277] New: clang hides the type of template arguments

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Oct 31 05:44:15 PDT 2011


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

             Bug #: 11277
           Summary: clang hides the type of template arguments
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: chris at bubblescope.net
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Consider the following simple code:
#include <vector>

typedef void* hidden_type;

int f(double d);

int main(void)
{
    hidden_type w;
    std::vector<hidden_type> v;
    f(w);
    f(v);
}

This produces as output:


t.cc:11:2: error: no matching function for call to 'f'
        f(w);
        ^
t.cc:5:5: note: candidate function not viable: cannot convert argument of
      incomplete type 'hidden_type' (aka 'void *') to 'double'
int f(double d);
    ^
t.cc:12:2: error: no matching function for call to 'f'
        f(v);
        ^
t.cc:5:5: note: candidate function not viable: no known conversion from
      'std::vector<hidden_type>' to 'double' for 1st argument;
int f(double d);
    ^

Notice how I am told in the first error that 'hidden_type' is void*, but in the
second case I am just given std::vector<hidden_type>.

In code I had this actually occur in, the type argument was a much more
complicated template monstrosity, and in the end I had to introduce a new error
into my code just to get the compiler to tell me what the 'hidden_type'
actually was.

As g++ seems to not track template arguments, in this case it produces the more
helpful:

t.cc:11:5: error: cannot convert ‘hidden_type {aka void*}’ to ‘double’ for
argument ‘1’ to ‘int f(double)’
t.cc:12:5: error: cannot convert ‘std::vector<void*>’ to ‘double’ for argument
‘1’ to ‘int f(double)’

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list