This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Namespace 'using' at global scope, recently broken

>> Simple attempts at namespace 'using' directives with global 
>> scope mis-fire with the 08-24 snapshot.  This did work fairly     
>> recently.                                                                

>You did not mention what the error message is. I get      

> conflicting types for `class ::Some::Display'    
>/usr/include/X11/Xlib.h:480: previous declaration as 
>`typedef struct _XDisplay Display'   
> using directive `Display' introduced ambiguous type 

That's right.

>This seems like an error to me: X11R6 defines a global type called
>Display, and your using declaration also introduces a global type
>(i.e. a member of the default namespace) with the name Display.  This
>is an error.

You may be right, but I am not convinced.  From the CD2 version
of the standard, in

" During unqualified name look up (_basic.lookup.unqual_),  
  the names appear as if they were declared in
  the nearest enclosing namespace which contains both  the  
  using-direc-tive  and the nominated namespace.  [Note: in this 
  context, "contains" means "contains directly or indirectly".  ] 
  A using-directive does not add any members to the declarative 
  region in which it appears."

I interpret that last sentence to be at odds with your explanation,
and expect the "appear as if" behavior to be what I intentended in
my example code (overriding the unqualified name 'Display').
On the other hand, it is possible that what this text meant to
convey (somewhat uncessarily in this context) is that the using
directive doesn't have any effect in other places where it is
not applied (in my example, I don't expect it to have any effect
in other translation units).

I checked back and found that at least the August 03 egcs snapshot
agreed with the behavior I expected, so if someone changed this
intentionally they can probably speak up with their (probably
correct) interpretation.  

- Josh

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]