This is the mail archive of the gcc-bugs@gcc.gnu.org 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

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

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.

Alas, if you use the using directive, this is not an error,
yet. However, later unqalified lookup will find two types (::Display
and Some::Display), which is ambiguous, and therefore an error.

Earlier g++ snapshots did not detect these errors.

OTOH, if you have a function-scope using declaration, you introduce
Some::Display into the scope of the function. It then hides ::Display,
that's why it works.

Martin


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