title: Why clang does not find a function declared prior to the call site?
body: <p>I want to provide some sqrt wrapper functions for simd types, such that they can be used from templates together with std::sqrt.</p>
  
  <p>Now I have the problem, that they somehow are not visible. Only the ones defined in std can be used.</p>
  
  <p>This a highly reduced part of the code:</p>
  
  <pre><code>#include &lt;cmath&gt;
  #include &lt;pmmintrin.h&gt;
  
  using float_simd = __m128;
  using double_simd = __m128d;
  
  float_simd sqrt(float_simd a) { return _mm_sqrt_ps(a); }
  double_simd sqrt(double_simd a) { return _mm_sqrt_pd(a); }
  
  template &lt;typename T&gt;
  void do_fancy(T val) 
  {
      using std::sqrt;
      auto ret = sqrt(val);
      (void)ret;
  }
  
  int main() {
      double testDouble = 1.0; 
      float testFloat = 1.0f;
      double_simd testSimdDouble;
      float_simd testSimdFloat;
      do_fancy(testDouble);
      do_fancy(testFloat);
      do_fancy(testSimdDouble);
      do_fancy(testSimdFloat);
      return 0;
  }
  </code></pre>
  
  <p>Now clang gives this:</p>
  
  <pre><code>main.cpp:14:16: error: call to function 'sqrt' that is neither visible in the template definition nor found by argument-dependent lookup
      auto ret = sqrt(val);
                 ^
  main.cpp:25:5: note: in instantiation of function template specialization 'do_fancy&lt;__attribute__((__vector_size__(2 * sizeof(double)))) double&gt;' requested here
      do_fancy(testSimdDouble);
      ^
  main.cpp:8:13: note: 'sqrt' should be declared prior to the call site
  double_simd sqrt(double_simd a) { return _mm_sqrt_pd(a); }
              ^
  main.cpp:14:16: error: call to function 'sqrt' that is neither visible in the template definition nor found by argument-dependent lookup
      auto ret = sqrt(val);
                 ^
  main.cpp:26:5: note: in instantiation of function template specialization 'do_fancy&lt;__attribute__((__vector_size__(4 * sizeof(float)))) float&gt;' requested here
      do_fancy(testSimdFloat);
      ^
  main.cpp:7:12: note: 'sqrt' should be declared prior to the call site
  float_simd sqrt(float_simd a) { return _mm_sqrt_ps(a); }
             ^
  </code></pre>
  
  <p>It says, that the simd sqrt functions "should be declared prior to the call site", but I think they are.</p>
  
  <p>I did a web search, but unfortunately I only found cases, where the order of call and declaration actually was wrong.</p>
  
  <p>I just commented out the <code>using std::sqrt</code> and everything works fine. I don't get it... How it is able to find the std::sqrt ones now?</p>
  
  <p>I use clang 3.9.1 from homebrew on macOS.</p>