[LLVMbugs] [Bug 22945] New: Missing expansion of function parameter pack from early substitution of explicit template arguments

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Mar 17 16:53:20 PDT 2015


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

            Bug ID: 22945
           Summary: Missing expansion of function parameter pack from
                    early substitution of explicit template arguments
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hstong at ca.ibm.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

N3290 subclause 14.8.2 [temp.deduct] paragraphs 2 to 5 specifies that explicit
template arguments are substituted into the type of the function template prior
to template argument deduction.
In the case below, Clang rejects the call to "foo" (but adding -DUSE_DEFAULT
makes it work, which seems to indicate that it understands that the "A<N> *..."
expands to "A<0> *").
If substitution is performed on the type of "foo" such that "A<N> *..." expands
to "A<0> *", then the case of foo/bar should behave like zip/zap, but that it
not the case with Clang.

### SOURCE (<stdin>):
#if USE_DEFAULT
# define DEFAULT_ARG = int
#else
# define DEFAULT_ARG
#endif

template <int> struct A { };

template <typename T> void zip(A<0> *ap, T);
void zap() { zip(0, 0); }

template <int ...N, typename T DEFAULT_ARG> void foo(A<N> *..., T);
void bar() { foo<0>(0, 0); }


### COMPILER INVOCATION:
clang -cc1 -std=c++11 -x c++ -


### ACTUAL OUTPUT:
<stdin>:13:14: error: no matching function for call to 'foo'
void bar() { foo<0>(0, 0); }
             ^~~~~~
<stdin>:12:50: note: candidate template ignored: couldn't infer template
argument 'T'
template <int ...N, typename T DEFAULT_ARG> void foo(A<N> *..., T);
                                                 ^
1 error generated.


### EXPECTED OUTPUT:
Clean compile.


### COMPILER VERSION INFO:
clang version 3.7.0 (trunk 232493) (llvm/trunk 232485)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation:
/usr/local/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2
Selected GCC installation:
/usr/local/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2
Candidate multilib: .;@m64
Selected multilib: .;@m64

-- 
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/20150317/49462caa/attachment.html>


More information about the llvm-bugs mailing list