<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 for reference conversion template discards cv-qualifiers"
   href="http://llvm.org/bugs/show_bug.cgi?id=20783">20783</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Deduction for reference conversion template discards cv-qualifiers
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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++11
          </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>Template argument deduction for reference conversions do not deduce the correct
type with respect to cv-qualifiers of the deduced A.

See N3290 subclause 14.8.2.3 [temp.deduct.conv]; the P/A pair used for type
deduction in the case below would be T/const int.
Deduction should succeed with T = const int.

As the error message shows, the deduction produced "int" instead of "const
int".

### SOURCE:
$ cat deduceTemplateConv.cc 
struct A {
  template <typename T> operator T&() { static_assert(sizeof(T) == 0, ""); }
};
template <> A::operator const int &(void);

const int &x = A();


### COMPILER INVOCATION AND OUTPUT:
$ clang -x c++ -std=c++11 deduceTemplateConv.cc 
deduceTemplateConv.cc:2:41: error: static_assert failed ""
  template <typename T> operator T&() { static_assert(sizeof(T) == 0, ""); }
                                        ^             ~~~~~~~~~~~~~~
deduceTemplateConv.cc:6:16: note: in instantiation of function template
specialization 'A::operator int &<int>' requested here
const int &x = A();
               ^
1 error generated.


### EXPECTED OUTPUT:
Successful compile.


### COMPILER VERSION INFO:
$ clang++ -v
clang version 3.6.0 (trunk 215824)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Candidate multilib: .;@m64
Selected multilib: .;@m64</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>