From -1535629388478700960
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,8117e5706dc0b4bb
X-Google-Attributes: gidf78e5,public
From: shepherd@debussy.sbi.com (Marc Shepherd)
Subject: Re: Redundant Using Declarations
Date: 1995/05/24
Message-ID: <3pvffk$jo5@offas_dike.sbil.co.uk>#1/1
X-Deja-AN: 103256132
distribution: world
references: <D8xsur.Ew2@ucc.su.OZ.AU>
organization: Salomon Brothers Inc
reply-to: shepherd@debussy.sbi.com
newsgroups: comp.std.c++

In article Ew2@ucc.su.OZ.AU, maxtal@Physics.usyd.edu.au (John Max Skaller) writes:
>In article <3pi75q$ihm@offas_dike.sbil.co.uk>,
>Marc Shepherd <shepherd@debussy.sbi.com> wrote:
::Subclause 7.3.3 of the draft WP says:
::
::   A using-declaration is a declaration and can therefore be
::   used repeatedly where (and only where) multiple declarations
::   are allowed.
>
>	No: a definition is also a declaration, and it _cannot_
>be repeated: it isn't a question of where "multiple declarations"
>are allowed: multiple definitions in the one scope are never
>allowed, and multiple declarations which are not definitions
>always are. (Multiple declarations which are not definitions
>must obey certain rules about not changing linkage attributes 
>or type or return type)

I'm not sure what you're saying "no" to.  The passage above was
quoted directly from the WP.  Are you saying the WP is incorrect?

::
::It further gives the following examples of this rule:
::
::   namespace A {
::      int i;
::   }
::
::   namespace A1 {
::      using A::i;
::      using A::i; // ok: double declaration
::   }
::
::   void f()
::   {
::      using A::i;
::      using A::i; // error: double declaration
::   }
::
::   class B {
::      int i;
::   };
::
::   class X : public B {
::      using B::i;
::      using B::i; // error: double member declaration
::   };
::
::My question is: in the definition of namespace A1 shown above, why
::is the redundant using declaration of A::i well-formed, considering
::that the following would not be:
::
::   namespace A1 {
::      int i;
::      int i;
::   }
>
>	Because the declaration "int i" is a definition.

I take your point.  I gave a bad example.  Let me give a better one.
I think we can agree that the following is well-formed:

   namespace A2 {
      using A::i;
      using A::i;     // ok: double declaration
      extern int j;
      extern int j;   // ok: double declaration
   }

Consider the following:

   void f()
   {
      using A::i;
      using A::i;     // error, according to the example from the WP quoted above
      extern int j;
      extern int j;   // my Sun 4.0 compiler accepts this,
                      // and I find no text in the WP that disallows it
   }

The two using declarations and the two extern declarations above are all
plain declarations, not definitions.  Yet, the redundant externs seem to
be well-formed, but the example in the WP says that the two using's are
not.

So, pardon my persistence, but it *still* seems to me that either the
normative text or the example--one or the other--is wrong.

---
Marc Shepherd
Salomon Brothers Inc
shepherd@schubert.sbi.com	The opinions I express are no one's but mine!




