<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Deduction succeeds despite type mismatch of non-type template parameter and deduced argument"
   href="http://llvm.org/bugs/show_bug.cgi?id=16279">16279</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Deduction succeeds despite type mismatch of non-type template parameter and deduced argument
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.2
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>other
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>hstong@ca.ibm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>clang++ does not consistently fail deduction for type mismatch of a non-type
template parameter and the corresponding deduced argument.

See N3690 subclause 14.8.2.5 [temp.deduct.type] paragraph 17.

### STANDALONE SOURCE:
template <short, char> struct A;

int foo(void *);
template <short x> int foo(A<x, x> *ap)
   // neither clang++ nor g++ bother to look at the second instance of x
   // for deduction
{ return noGood(ap); }

int bar(void *);
template <char y> int bar(A<y, y> *ap)
   // okay; clang++ and g++ both realize that deducing from the first instance
   // of y is no good
{ return noGood(ap); }

int zip(void *, void *);
template <short x, char y> int zip(A<x, y> *ap, A<y, x> *)
   // clang++ does not bother to look at the second function argument
   // for deduction, g++ does
{ return noGood(ap); }

A<0, 0> *ap = 0;

int a = foo(ap);  // clang++ and g++ both fail to fail the argument deduction
int b = bar(ap);  // clang++ and g++ both successfully fail the deduction
int c = zip(ap, ap);  //
   // clang++ fails to fail and g++ successfully fails the argument deduction

// For all three:
// - MSVC 17.00.51025 fails to fail the argument deduction
// - ICC 13.0.1 20121010 and IBM XL C/C++ for AIX 12.1.0.3 work fine


### COMPILER INVOCATION:
clang++ -std=c++11 -c main.cpp


### EXPECTED OUTPUT:
Successful compile.


### ACTUAL OUTPUT:
main.cpp:7:10: error: use of undeclared identifier 'noGood'
{ return noGood(ap); }
         ^
main.cpp:23:9: note: in instantiation of function template specialization
'foo<0>' requested here
int a = foo(ap);  // clang++ and g++ both fail to fail the argument deduction
        ^
main.cpp:19:10: error: use of undeclared identifier 'noGood'
{ return noGood(ap); }
         ^
main.cpp:25:9: note: in instantiation of function template specialization
'zip<0, '\x00'>' requested here
int c = zip(ap, ap);  //
        ^
2 errors generated.


### clang++ -v OUTPUT:
clang version 3.2 (trunk 158227)
Target: i386-pc-cygwin
Thread model: posix</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>