public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/3765: member using declaration can't change access from public
@ 2002-07-23  7:49 lerdsuwa
  0 siblings, 0 replies; 2+ messages in thread
From: lerdsuwa @ 2002-07-23  7:49 UTC (permalink / raw)
  To: dbaron, gcc-bugs, gcc-prs, nobody, scc

Synopsis: member using declaration can't change access from public

State-Changed-From-To: open->analyzed
State-Changed-By: lerdsuwa
State-Changed-When: Tue Jul 23 07:49:26 2002
State-Changed-Why:
    Confirmed.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=3765


^ permalink raw reply	[flat|nested] 2+ messages in thread

* c++/3765: member using declaration can't change access from public
@ 2001-07-22 18:56 dbaron
  0 siblings, 0 replies; 2+ messages in thread
From: dbaron @ 2001-07-22 18:56 UTC (permalink / raw)
  To: gcc-gnats; +Cc: scc

>Number:         3765
>Category:       c++
>Synopsis:       member using declaration can't change access from public
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          accepts-illegal
>Submitter-Id:   net
>Arrival-Date:   Sun Jul 22 18:56:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     David Baron
>Release:        gcc 3.0
>Organization:
>Environment:
Linux 2.2.14-5.0smp i686 (RedHat 6.2)
>Description:
A C++ using declaration cannot be used to change member access from public to private or from public to protected.  (Other combinations seem to work correctly.)  This is a regression that occurred between egcs 1.1.2 and gcc 2.95.2 and still exists in gcc 3.0.  (The error message given on the occasions where the |using| declaration works correctly also doesn't make much sense, since it gives the access that was overridden by the |using| even though it correctly changes the access.  But that's another bug.)

This is useful for things such as ensuring that users do not attempt to manually refcount an COM smart pointer:
http://lxr.mozilla.org/seamonkey/source/xpcom/base/nsCOMPtr.h#159
>How-To-Repeat:
Try to compile test case #1 or #4.  Compilation succeds even though it should not.

Test case #1:
===========
/* vim:cindent:ai:sw=2:et:ts=8:tw=72:
 *
 * Demonstration of bug in gcc 3.0 where |using| does not change access
 * from public to private. 
 *
 * ILLEGAL EXAMPLE
 * Test of changing access from public to private.
 *
 * See C++ standard, section 11.3 and 7.3.3.
 */

class A
{
  public:
    int foo() { return 1; }
};

class B : public A
{
  private:
    using A::foo;
};

int main()
{
  B b;
  return b.foo();   // Should not compile.
}
===========

Test case #2:
===========
/* vim:cindent:ai:sw=2:et:ts=8:tw=72:
 *
 * Demonstration of bug in gcc 3.0 where |using| does not change access
 * from public to private. 
 *
 * LEGAL EXAMPLE
 * Test of changing access from protected to public.
 *
 * See C++ standard, section 11.3 and 7.3.3.
 */

class A
{
  protected:
    int foo() { return 0; }
};

class B : public A
{
  public:
    using A::foo;
};

int main()
{
  B b;
  return b.foo();
}
===========

Test case #3:
===========
/* vim:cindent:ai:sw=2:et:ts=8:tw=72:
 *
 * Demonstration of bug in gcc 3.0 where |using| does not change access
 * from public to private. 
 *
 * ILLEGAL EXAMPLE
 * Test of changing access from protected to private.
 *
 * See C++ standard, section 11.3 and 7.3.3.
 */

class A
{
  protected:
    int foo() { return 1; }
};

class B : public A
{
  private:
  //protected:
    using A::foo;
};

class C : public B
{
  public:
    C() { B::foo(); }
};

int main()
{
  C c;
  return 1;
}
===========

Test case #4:
===========
/* vim:cindent:ai:sw=2:et:ts=8:tw=72:
 *
 * Demonstration of bug in gcc 3.0 where |using| does not change access
 * from public to private. 
 *
 * ILLEGAL EXAMPLE
 * Test of changing access from public to private.
 *
 * See C++ standard, section 11.3 and 7.3.3.
 */

class A
{
  public:
    int foo() { return 1; }
};

class B : public A
{
  private:
    using A::foo;
};

class C : public B
{
  public:
    C() { foo(); }
};

int main()
{
  C c;
  return 1;
}
===========

Test case #5:
===========
/* vim:cindent:ai:sw=2:et:ts=8:tw=72:
 *
 * Demonstration of bug in gcc 3.0 where |using| does not change access
 * from public to private. 
 *
 * LEGAL EXAMPLE
 * Test of changing access from protected to public.
 *
 * See C++ standard, section 11.3 and 7.3.3.
 */

class A
{
  protected:
    int foo() { return 0; }
};

class B : public A
{
  public:
    using A::foo;
};

int main()
{
  B b;
  return b.foo();
}
===========
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-07-23 14:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-23  7:49 c++/3765: member using declaration can't change access from public lerdsuwa
  -- strict thread matches above, loose matches on Subject: below --
2001-07-22 18:56 dbaron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).