[LLVMbugs] [Bug 15064] New: erroneous substitution failure

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jan 25 06:12:45 PST 2013


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

             Bug #: 15064
           Summary: erroneous substitution failure
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: joerg.richter at pdv-fs.de
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


cat > t.cc <<EOF
template<class T, class Enable = void> struct CFooEnabler {};

struct CFoo
{
    template<class T> inline CFoo( T const& t, typename CFooEnabler<T>::Enable*
= 0 );
    char const* data() const;
    int size() const;
};

template<> struct CFooEnabler<char const*>
{
    typedef void Enable;
    static char const* extract( char const* val );
};

template<class T, class Enable = void> struct FooEnabler {};
struct Foo
{
    template<class T> inline
    Foo( T const& t, typename FooEnabler<T>::Enable* = 0 );
    Foo( char const* str, int size );
};

template<> struct FooEnabler<CFoo>
{
    typedef void Enable;
    static Foo extract( CFoo val )     // make this a declaration and it works
    {
      return Foo( val.data(), val.size() );
    }
};

template<class T>
struct FooEnabler<T, typename CFooEnabler<T>::Enable> : FooEnabler<CFoo> {};

void func()
{
  char const* a = "";
  Foo xx( a );
}
EOF

clang++ t.cc     # version from 2013-01-25



Gives following output:
t.cc:39:7: error: no matching constructor for initialization of 'Foo'
  Foo xx( a );
      ^   ~
t.cc:17:8: note: candidate constructor (the implicit copy constructor) not
viable: no known conversion from
      'const char *' to 'const Foo' for 1st argument
struct Foo
       ^
t.cc:20:5: note: candidate template ignored: substitution failure [with T =
const char *]: no type named 'Enable' in
      'FooEnabler<const char *, void>'
    Foo( T const& t, typename FooEnabler<T>::Enable* = 0 );
    ^                                        ~~~~~~
t.cc:21:5: note: candidate constructor not viable: requires 2 arguments, but 1
was provided
    Foo( char const* str, int size );
    ^
1 error generated.


I think
   Foo( T const& t, typename FooEnabler<T>::Enable* = 0 );
should match.  At least GCC 4.7.2 supports my opinion.


Please see the comment on FooEnabled<CFoo>::extract member function.

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