http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48046

           Summary: [4.5/4.6 Regression] Expected diagnostic "reference to
                     'type' is ambiguous" not given for function-local
                    static declaration
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: dev.li...@jessamine.co.uk


In g++ 4.5 and 4.6, a function-local static declared with an ambiguous type
does not yield the expected diagnostic.  It appropriately fails to compile due
to a type not being resolved but doesn't give the user the root cause of the
failure as it did in 4.4.

Given the following code:

   namespace N1 { typedef int   T; }
   namespace N2 { typedef float T; }

   int main()
   {
      using namespace N1;
      using namespace N2;

      static T t;
   }

4.4.5 outputs:

  <stdin>: In function 'int main()':
  <stdin>:9: error: reference to 'T' is ambiguous
  <stdin>:2: error: candidates are: typedef float N2::T
  <stdin>:1: error:                 typedef int N1::T
  <stdin>:9: error: 'T' does not name a type

Both 4.5.0 (an old build I had lying around) and 4.6.0 (at rev 170646) output:

  <stdin>: In function ‘int main()’:
  <stdin>:9:14: error: ‘T’ does not name a type

If the static declaration and preceding using directives are moved to namespace
scope rather than being function-local, the expected diagnostic is output.

If the function-local declaration is made non-static, the expected diagnostic
is output.

Reply via email to