Is a static member function of a function-scoped struct of a function template considered a dependent scope?
<p>MSVC 9 and g++-4.5 disagree over the use of <code>typename</code> within <code>nested::baz</code> below.  Which is correct?</p>

<pre><code>template&lt;typename T&gt;
  struct foo
{
  typedef T type;
};

template&lt;typename T&gt;
  typename foo&lt;T&gt;::type
    bar(T x)
{
  struct nested
  {
    inline static typename foo&lt;T&gt;::type baz(T x)
    {
      typename foo&lt;T&gt;::type result;
      return result;
    }
  };

  return nested::baz(x);
}

int main()
{
  int x;
  bar(x);

  return 0;
}
</code></pre>

<p>MSVC's output:</p>

<pre><code>$ cl test.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

test.cpp
test.cpp(15) : error C2899: typename cannot be used outside a template declaration
</code></pre>

<p>g++-4.5 issues no error, but if I remove the offending <code>typename</code>, I receive an error message:</p>

<pre><code>$ g++-4.5 test.cpp
test.cpp: In static member function 'static typename foo&lt;T&gt;::type bar(T)::nested::baz(T)':
test.cpp:15:7: error: need 'typename' before 'foo&lt;T&gt;::type' because 'foo&lt;T&gt;' is a dependent scope
test.cpp:15:20: error: expected ';' before 'result'
test.cpp:16:14: error: 'result' was not declared in this scope
test.cpp: In static member function 'static typename foo&lt;T&gt;::type bar(T)::nested::baz(T) [with T = int, typename foo&lt;T&gt;::type = int]':
test.cpp:20:23:   instantiated from 'typename foo&lt;T&gt;::type bar(T) [with T = int, typename foo&lt;T&gt;::type = int]'
test.cpp:26:8:   instantiated from here
test.cpp:15:7: error: dependent-name 'foo&lt;T&gt;::type' is parsed as a non-type, but instantiation yields a type
test.cpp:15:7: note: say 'typename foo&lt;T&gt;::type' if a type is meant
</code></pre>

<p>Which is correct in this instance?</p>
