title: VS2008(+?) compiler bug with templated functions and 'using namespace'
body: <p>I've found this odd case of some code (below) doesn't compile under Visual Studio 2008 and produces an "error C2872: 'Ambiguity' : ambiguous symbol" on line 12. </p>
  
  <p>Removing the using <code>namespace RequiredNamespace</code> on the last line fixes the error, but I'd expect that putting <code>using namespace</code> at the end of a file should have no effect. It also relies on <code>AnotherFunction</code> being a template function, so I expect the compiler is generating the templated functions in the wrong scope, or isn't resetting the list of namespaces being used before doing so.</p>
  
  <p>The same code compiles under GCC.</p>
  
  <p>Both compilers seem to generate the code for <code>TemplatedFunction</code> after the <code>using namespace Namespace</code> definition, at least as far as I can tell by introducing errors and looking at the order they're output.</p>
  
  <pre><code>namespace Ambiguity
  {
      class cSomeClass
      {
      };
  
      template&lt;class T&gt;
      void TemplatedFunction(T a)
      {
          // this is where the error occurs, the compiler thinks Ambiguity
          // might refer to the class in RequiredNamespace below
          Ambiguity::cSomeClass(); 
      }
  }
  
  namespace RequiredNamespace 
  {
      // without a namespace around this class, the Ambiguity class 
      // and namespace collide
      class Ambiguity
      {
      };
  }
  
  int main()
  {
      // to force the templated function to be generated
      Ambiguity::TemplatedFunction(4); 
  }
  
  // removing this removes the error, but it shouldn't really do anything
  using namespace RequiredNamespace; 
  </code></pre>
  
  <p>Obviously this is a manufactured example, but the original is extracted from a real case where the <code>using namespace</code> is in a auto-generated file produced by 3rd party code.</p>
  
  <p>Is this a bug in the compiler?</p>