[llvm-bugs] [Bug 46377] New: Parameter pack not expanded in typedef for function type

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jun 18 02:27:34 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=46377

            Bug ID: 46377
           Summary: Parameter pack not expanded in typedef for function
                    type
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zilla at kayari.org
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

template<typename T, typename U>
struct require_same;

template<typename T> struct require_same<T,T>
{ };

template<typename T> using int_t = int;

void (*f)();

template<typename ...Ts>
void g(Ts... args) {

  // This works
  ((void (*)(int_t<Ts>...)) f)(args...);

  // This works
  using funcptr = void (*)(decltype((void)args, 0)...);
  ((funcptr) f)(args...);

  // This is wrong
  using funcptr2 = void (*)(int_t<Ts>...);
  // The type funcptr2 only has a single parameter, pack not expanded
  require_same<funcptr, funcptr2> chk;

  // So this fails
  ((funcptr2) f)(args...);
}

void h(int x, int y) { g(x, y); }


This works with Clang 3.0 but fails with anything later. This prevents building
GCC master with Clang.

var.cc:24:35: error: implicit instantiation of undefined template
'require_same<void (*)(int, int), void (*)(int)>'
  require_same<funcptr, funcptr2> chk;
                                  ^
var.cc:30:24: note: in instantiation of function template specialization
'g<int, int>' requested here
void h(int x, int y) { g(x, y); }
                       ^
var.cc:2:8: note: template is declared here
struct require_same;
       ^
var.cc:27:18: error: too many arguments to function call, expected 1, have 2
  ((funcptr2) f)(args...);
  ~~~~~~~~~~~~~~ ^~~~
2 errors generated.

-- 
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/20200618/81a366ab/attachment.html>


More information about the llvm-bugs mailing list