[llvm-bugs] [Bug 33195] New: Incorrect arguments matching in a template class constructor

via llvm-bugs llvm-bugs at lists.llvm.org
Sat May 27 09:51:32 PDT 2017


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

            Bug ID: 33195
           Summary: Incorrect arguments matching in a template class
                    constructor
           Product: clang
           Version: 4.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: dvtikhomirov at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

Created attachment 18524
  --> https://bugs.llvm.org/attachment.cgi?id=18524&action=edit
Compilation error

The following program causes compilation error in the Outer class constructor
while the Function is compiled without any problems:

#include <tuple>

struct Inner {
  Inner(const char *) {}
};

template <typename T> struct Middle {
  Middle(const int &, const T & = {}) {}
};

template <typename... Ts> struct Outer {
  Outer(const std::tuple<Middle<Ts>...> &, void * = nullptr) {}
};

template <typename... Ts>
void Function(const std::tuple<Middle<Ts>...> &, void * = nullptr) {}

int main() {
  // Compiles ok
  Function<Inner, Inner>({{1, "a"}, {2, "b"}});
  // Compilation error
  Outer<Inner, Inner>({{1, "a"}, {2, "b"}});
  return 0;
}

Looks like for some reason clang thinks that tuple's argument is {1, "a"}, not
{{1, "a"}, {2, "b"}}.
If you remove the void* argument from the Outer's constructor, or remove the
default value of T from Middle's constructor, the compilation succeeds.
GCC compiles this without any errors.

clang version 4.0.0 (tags/RELEASE_400/final)
Target: x86_64-unknown-linux-gnu
System: Arch linux

-- 
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/20170527/fed1d43e/attachment-0001.html>


More information about the llvm-bugs mailing list