[LLVMbugs] [Bug 10976] New: Bad error message with bound member function

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Sep 21 04:48:11 PDT 2011


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

           Summary: Bad error message with bound member function
           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: llvmbugs at cs.uiuc.edu, dgregor at apple.com


The following code:

#include <iostream>

struct V
{
    int size();
    int size() const;
};

void print(V v)
{ std::cout << v.size; }

Produces the following. I am not sure if it would be possible to give a lot
less suggestions here. Also, in general only giving 1 or 2 (or 3?) overloads
might be sensible. I imagine it is only for operator<<(ostream&, T) (or
equivalently operator>>(istream&, T) that commonly so many possible overloads
exist in C++.


t.cc:10:16: error: a bound member function may only be called
{ std::cout << v.size; }
               ^~~~~~
/usr/include/c++/4.6/ostream:226:7: note: candidate function not viable: no
known conversion from
      '<bound member function type>' to 'const void *' for 1st argument; take
the address of the argument with &
      operator<<(const void* __p)
      ^
/usr/include/c++/4.6/ostream:109:7: note: candidate function not viable: no
known conversion from
      '<bound member function type>' to '__ostream_type &(*)(__ostream_type &)'
for 1st argument;
      operator<<(__ostream_type& (*__pf)(__ostream_type&))
      ^
/usr/include/c++/4.6/ostream:118:7: note: candidate function not viable: no
known conversion from
      '<bound member function type>' to '__ios_type &(*)(__ios_type &)' for 1st
argument;
      operator<<(__ios_type& (*__pf)(__ios_type&))
      ^
/usr/include/c++/4.6/ostream:128:7: note: candidate function not viable: no
known conversion from
      '<bound member function type>' to 'std::ios_base &(*)(std::ios_base &)'
for 1st argument;
      operator<<(ios_base& (*__pf) (ios_base&))
      ^
/usr/include/c++/4.6/ostream:166:7: note: candidate function not viable: no
known conversion from
      '<bound member function type>' to 'long' for 1st argument;
      operator<<(long __n)
      ^
/usr/include/c++/4.6/ostream:170:7: note: candidate function not viable: no
known conversion from
      '<bound member function type>' to 'unsigned long' for 1st argument;
      operator<<(unsigned long __n)
      ^
/usr/include/c++/4.6/ostream:174:7: note: candidate function not viable: no
known conversion from
      '<bound member function type>' to 'bool' for 1st argument;
      operator<<(bool __n)
      ^
/usr/include/c++/4.6/ostream:178:7: note: candidate function not viable: no
known conversion from
      '<bound member function type>' to 'short' for 1st argument;
      operator<<(short __n);
      ^
/usr/include/c++/4.6/ostream:181:7: note: candidate function not viable: no
known conversion from
      '<bound member function type>' to 'unsigned short' for 1st argument;
      operator<<(unsigned short __n)
      ^
/usr/include/c++/4.6/ostream:189:7: note: candidate function not viable: no
known conversion from
      '<bound member function type>' to 'int' for 1st argument;
      operator<<(int __n);
      ^
/usr/include/c++/4.6/ostream:192:7: note: candidate function not viable: no
known conversion from
      '<bound member function type>' to 'unsigned int' for 1st argument;
      operator<<(unsigned int __n)
      ^
/usr/include/c++/4.6/ostream:201:7: note: candidate function not viable: no
known conversion from
      '<bound member function type>' to 'long long' for 1st argument;
      operator<<(long long __n)
      ^
/usr/include/c++/4.6/ostream:205:7: note: candidate function not viable: no
known conversion from
      '<bound member function type>' to 'unsigned long long' for 1st argument;
      operator<<(unsigned long long __n)
      ^
/usr/include/c++/4.6/ostream:210:7: note: candidate function not viable: no
known conversion from
      '<bound member function type>' to 'double' for 1st argument;
      operator<<(double __f)
      ^
/usr/include/c++/4.6/ostream:214:7: note: candidate function not viable: no
known conversion from
      '<bound member function type>' to 'float' for 1st argument;
      operator<<(float __f)
      ^
/usr/include/c++/4.6/ostream:222:7: note: candidate function not viable: no
known conversion from
      '<bound member function type>' to 'long double' for 1st argument;
      operator<<(long double __f)
      ^
/usr/include/c++/4.6/ostream:251:7: note: candidate function not viable: no
known conversion from
      '<bound member function type>' to '__streambuf_type *'
      (aka 'basic_streambuf<char, std::char_traits<char> > *') for 1st
argument;
      operator<<(__streambuf_type* __sb);
      ^
/usr/include/c++/4.6/ostream:455:5: note: candidate function [with _CharT =
char, _Traits = std::char_traits<char>]
      not viable: no known conversion from '<bound member function type>' to
'char' for 2nd argument;
    operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)
    ^
/usr/include/c++/4.6/ostream:461:5: note: candidate function [with _Traits =
std::char_traits<char>] not viable: no
      known conversion from '<bound member function type>' to 'char' for 2nd
argument;
    operator<<(basic_ostream<char, _Traits>& __out, char __c)
    ^
/usr/include/c++/4.6/ostream:467:5: note: candidate function [with _Traits =
std::char_traits<char>] not viable: no
      known conversion from '<bound member function type>' to 'signed char' for
2nd argument;
    operator<<(basic_ostream<char, _Traits>& __out, signed char __c)
    ^
/usr/include/c++/4.6/ostream:472:5: note: candidate function [with _Traits =
std::char_traits<char>] not viable: no
      known conversion from '<bound member function type>' to 'unsigned char'
for 2nd argument;
    operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)
    ^
/usr/include/c++/4.6/ostream:509:5: note: candidate function [with _Traits =
std::char_traits<char>] not viable: no
      known conversion from '<bound member function type>' to 'const char *'
for 2nd argument;
    operator<<(basic_ostream<char, _Traits>& __out, const char* __s)
    ^
/usr/include/c++/4.6/ostream:522:5: note: candidate function [with _Traits =
std::char_traits<char>] not viable: no
      known conversion from '<bound member function type>' to 'const signed
char *' for 2nd argument;
    operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)
    ^
/usr/include/c++/4.6/ostream:527:5: note: candidate function [with _Traits =
std::char_traits<char>] not viable: no
      known conversion from '<bound member function type>' to 'const unsigned
char *' for 2nd argument;
    operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)
    ^
/usr/include/c++/4.6/bits/ostream.tcc:322:5: note: candidate function [with
_CharT = char, _Traits =
      std::char_traits<char>] not viable: no known conversion from '<bound
member function type>' to 'const char *'
      for 2nd argument;
    operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)
    ^
/usr/include/c++/4.6/ostream:450:5: note: candidate template ignored: deduced
conflicting types for parameter
      '_CharT' ('char' vs. '<bound member function type>')
    operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)
    ^
/usr/include/c++/4.6/bits/basic_string.h:2692:5: note: candidate template
ignored: failed template argument
      deduction
    operator<<(basic_ostream<_CharT, _Traits>& __os,
    ^
/usr/include/c++/4.6/ostream:492:5: note: candidate template ignored: failed
template argument deduction
    operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)
    ^
1 error generated.

-- 
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