title: g++, bitfields and ADL
body: <p>g++ fails to compile following code snippet:</p>
  
  <pre><code>namespace X {
    enum En {A, B};
    bool test(En e);
  }
  
  bool check() {
    union {
      struct {
        X::En y:16;
        X::En z:16; 
      } x;
      int z;
    } zz;
    return test(zz.x.y);
  }
  </code></pre>
  
  <p>The error it gives is following</p>
  
  <blockquote>
    <p>In function 'bool check()': 15 : error: 'test' was not declared in
    this scope return test(zz.x.y); ^ 15 : note: suggested alternative: 3
    : note: 'X::test' bool test(En e); ^~~~ Compilation failed</p>
  </blockquote>
  
  <p>If i make <code>y</code> a regular member, rather than a bitfield, code compiles successfully. Calling a name-spaced <code>test</code> works as well. Clang compiles the program as-is without any complains.</p>
  
  <p>Putting bitfield business aside  (I do not love it at all, but codebase has it) and not focusing on whether I have a guarantee of fitting an enum into the 16-bit member or not, is there something special regarding bitfields which prevents ADL from kicking in as I expect it?</p>