http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61134

            Bug ID: 61134
           Summary: [4.7/4.8/4.9/4.10 Regression][C++11] bogus "no
                    matching function for call..."
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ppluzhnikov at google dot com

Google ref: b/14657431

The test case compiles with Clang and gcc-4.6, fails with -DBUG on all later
versions including current trunk (r210292):

g++ -c -std=gnu++11 t.cc && echo OK && g++ -c -std=gnu++11 t.cc -DBUG
OK
t.cc: In function 'void Fn()':
t.cc:22:55: error: no matching function for call to 'CreateMetric(const char
[5], const char [4], Base)'
   CreateMetric<int, const char*>("abcd", "def", Base());
                                                       ^
t.cc:22:55: note: candidate is:
t.cc:15:6: note: template<class VT, class ... Fields> void CreateMetric(const
char*, typename Fixed<Fields>::name ..., const Base&)
 void CreateMetric(const char* name,
      ^
t.cc:15:6: note:   template argument deduction/substitution failed:
t.cc:22:55: note:   cannot convert '"def"' (type 'const char [4]') to type
'const Base&'
   CreateMetric<int, const char*>("abcd", "def", Base());
                                                       ^

// --- cut ---
struct Base { };

template <typename>
struct Fixed {
  typedef const char* name;
};

#if BUG
template <typename VT, typename... Fields>
void New(const char* name,
         typename Fixed<Fields>::name... field_names);
#endif

template <typename VT, typename... Fields>
void CreateMetric(const char* name,
                  typename Fixed<Fields>::name... field_names,
                  const Base&) { }


void Fn()
{
  CreateMetric<int, const char*>("abcd", "def", Base());
}
// --- cut ---


Note: The 'New()' function is not referenced outside the #ifdef block.
      It's mere presense triggers the bug.

Reply via email to