c++/10437: "using namespace" at global scope creates incorrect code

Wolfgang Bangerth bangerth@ices.utexas.edu
Mon Apr 21 20:03:00 GMT 2003


> I'm willing to agree that that I've have an error/ambiguity in my
> code.  But I don't understand why bringing in a namespace that isn't
> being called should change the ambiguity status.

The point is that in order to find out which function the compiler 
shall take, it needs to know about the possibilities. For this, the
possible declarations must "work". Without knowing your choices, you can't 
perform overload resolution.


> In other words,
> 
> 		main()
> 		{
> 		  using namespace foo;
> 		  /* ... */           // no error
> 		}
> doesn't generate an error. But, the following does generate an error:
> 		  
> 		using namespace foo;
> 		main()
> 		{
> 		  /* ... */         // generates error
> 		}
> 
> It seems that [they] should be the same. 

I guess that should be so.

I can't reproduce this with the small example I posted. Can you try to 
come up with something short that shows this? Your original example was 
incredibly contrived, and I don't want to go through the ordeal again of 
reducing it, which took me well over an hour. Hint: try stripping template 
parameters, and replacing typedefs by the types the point to, etc. Once 
it's well below 100 lines I'll be willing to look at it again :-)

W.

-------------------------------------------------------------------------
Wolfgang Bangerth              email:            bangerth@ices.utexas.edu
                               www: http://www.ices.utexas.edu/~bangerth/




More information about the Gcc-bugs mailing list