Bug 43145

Summary: local extern declaration gets wrong namespace
Product: gcc Reporter: Jason Merrill <jason>
Component: c++Assignee: Jason Merrill <jason>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs, pinskia
Priority: P3 Keywords: patch, wrong-code
Version: 4.5.0   
Target Milestone: 4.6.0   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2010-02-22 20:50:04
Bug Depends on:    
Bug Blocks: 41998    
Attachments: patch for 4.6

Description Jason Merrill 2010-02-22 20:48:56 UTC
For this testcase:

namespace N {
  void f();
}

void N::f()
{
  extern int i;
  extern void g();
  i = 1;
  g();
}

namespace N {
  int i;
  void g() { }
}

int main() { }

we end up with unsatisfied references to ::i and ::g.
Comment 1 Jason Merrill 2010-02-22 20:49:46 UTC
Created attachment 19937 [details]
patch for 4.6
Comment 2 Andrew Pinski 2010-03-13 01:29:16 UTC
If f is done inside "namespace N{}", it works
Comment 3 Jason Merrill 2010-05-04 04:51:21 UTC
Fixed for 4.6.