public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/10841: rejects valid explicit conversion to/from pointers-to-member of private base
@ 2003-05-18  5:16 sbeasley
  0 siblings, 0 replies; only message in thread
From: sbeasley @ 2003-05-18  5:16 UTC (permalink / raw)
  To: gcc-gnats


>Number:         10841
>Category:       c++
>Synopsis:       rejects valid explicit conversion to/from pointers-to-member of private base
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Sun May 18 05:16:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Shane Beasley
>Release:        gcc version 3.3 20030415 (Debian prerelease)
>Organization:
>Environment:
Linux v2.4.19 (Debian) on Intel x86-compatible
>Description:
Section 5.4, paragraph 7, of ISO/IEC 14882:1998 (ISO C++) allows C-style cast notation to convert a pointer-to-member of a derived class to a pointer-to-member of a unambiguous non-virtual base class or vice versa, regardless of the accessibility of the base class.

GCC 3.3 emits the following diagnostic:

<stdin>: In function `int main()':
<stdin>:9: error: `main()::Base' is an inaccessible base of `main()::Derived'
<stdin>:10: error: `main()::Base' is an inaccessible base of `main()::Derived'
>How-To-Repeat:
int main () {
  class Base { public: int i, j, k; };
  class Derived : private Base { public: int m, n, p; };

  Derived derived;
  Base &base = (Base &)derived;

  // neither line compiles; 5.4p7 allows both
  base.*((int Base::*)&Derived::n) = 0xdeadbeef;
  derived.*((int Derived::*)&Base::j) = 0xc0decafe;
}
>Fix:
Do not check for accessibility of the base class if C-style cast notation is used.
>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-05-18  5:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-18  5:16 c++/10841: rejects valid explicit conversion to/from pointers-to-member of private base sbeasley

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).