title: No ambiguous reference error even after using namespace directive
body: <p>The following code generates <code>call of overloaded ‘bar()’ is ambiguous</code> error which it should be as I have a function <code>bar</code> in both global and <code>foo</code> namespace and I have called <code>using namespace foo</code> directive.</p>
  
  <pre><code>namespace foo {
      void bar() {}
  }
  
  void bar() {}
  
  using namespace foo;
  
  int main() {
      bar();
  }
  </code></pre>
  
  <p>I was expecting the same error with the following code too:</p>
  
  <pre><code>#include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  
  int abs(int n) {
      return n &gt; 0 ? n : -n;
  }
  
  using namespace std;
  
  int main() {
      int k;
  
      cin &gt;&gt; k;
  
      cout &lt;&lt; abs(k) &lt;&lt; endl;
  }
  </code></pre>
  
  <p>I have defined a function <code>int abs(int n)</code> like the one present in <a href="http://en.cppreference.com/w/cpp/numeric/math/abs" rel="noreferrer">cstlib</a> and I have called <code>using namespace std</code> directive. So there should have been an error like the first example. But there is none. </p>
  
  <p>My question is how the compiler is resolving this ambiguity? Which function will be called in such cases, mine or <code>std</code>'s one? Is there any UB involved here?</p>
  
  <p><strong>Update</strong>: From comments and answers it seems that different compilers are behaving differently. So is this behavior undefined or implementation defined?</p>
  
  <p>I have tested it with <code>g++ 4.8.4</code> on <code>Ubuntu 14.04</code> with <code>-std=c++11</code> flag.</p>
  
  <p>[Please note that I do understand that <code>using namespace std</code> is bad and my <code>abs</code> function is no better or even worse than <code>std</code> one. My question is different.]</p>