title: bit-field in overload resolution for template
body: <p>Anyone knows why the first program compiles but second one doesn't?  The only difference is that the first one uses normal function but the second one uses template function.  Why the overload resolution behaves differently on bitfield for template and non-template function?</p>
  
  <p>Please refer to paragraphs in standard when answering.  Thanks.</p>
  
  <p>a.cpp</p>
  
  <pre><code>struct X {
    int x : 20;
    int y : 12;
  };
  
  void f(const int&amp; x) {}
  
  void f(int&amp;&amp; x) {}
  
  int main() {
    X x;
    f(x.x);
  }
  </code></pre>
  
  <p>b.cpp</p>
  
  <pre><code>struct X {
    int x : 20;
    int y : 12;
  };
  
  template &lt;typename T&gt;
  void f(T&amp;&amp; x) {}
  
  template &lt;typename T&gt;
  void f(const T&amp; x) {}
  
  int main() {
    X x;
    f(x.x);
  }
  </code></pre>
  
  <p>Compiler errors:</p>
  
  <pre><code>[hidden]$ g++ -v 2&gt;&amp;1 | tail -n 1
  gcc version 4.7.2 20120921 (Red Hat 4.7.2-2) (GCC)
  [hidden]$ clang++ -v 2&gt;&amp;1 | head -n 1
  clang version 3.3
  [hidden]$ g++ -std=c++11 a.cpp
  [hidden]$ g++ -std=c++11 b.cpp
  b.cpp: In function ‘int main()’:
  b.cpp:14:8: error: cannot bind bitfield ‘x.X::x’ to ‘int&amp;’
  [hidden]$ clang++ -std=c++11 a.cpp
  [hidden]$ clang++ -std=c++11 b.cpp
  b.cpp:14:5: error: non-const reference cannot bind to bit-field 'x'
    f(x.x);
      ^~~
  b.cpp:2:7: note: bit-field is declared here
    int x : 20;
        ^
  1 error generated.
  </code></pre>