public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/8500: Allows cast to private base class
@ 2002-11-11 4:16 Gabriel Dos Reis
0 siblings, 0 replies; 4+ messages in thread
From: Gabriel Dos Reis @ 2002-11-11 4:16 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c++/8500; it has been noted by GNATS.
From: Gabriel Dos Reis <gdr@integrable-solutions.net>
To: gcc-gnats@gcc.gnu.org
Cc:
Subject: Re: c++/8500: Allows cast to private base class
Date: 11 Nov 2002 12:36:48 +0100
Wolfgang Bangerth <bangerth@ticam.utexas.edu> writes:
| The following reply was made to PR c++/8500; it has been noted by GNATS.
|
| From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
| To: "Harald H. Soleng" <Harald.Soleng@nr.no>
| Cc: gcc-gnats@gcc.gnu.org
| Subject: Re: c++/8500: Allows cast to private base class
| Date: Fri, 8 Nov 2002 14:03:20 -0600 (CST)
|
| > You should not get an error with old style c-casting.
| > However, with
| >
| > Base* b1 = static_cast<Base*> d1;
| >
| > on the second line of main you should. Here is the error message from
| > the native Sun CC compiler:
| > "Error: Using static_cast to convert from Derived* to Base* not allowed."
|
| Uhm, I don't think you can work around access control rules just by using
| a C-style cast over a static_cast, can you?
old-style casts don't chech acess control. New-style casts do, however.
-- Gaby
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: c++/8500: Allows cast to private base class
@ 2002-11-08 12:06 Wolfgang Bangerth
0 siblings, 0 replies; 4+ messages in thread
From: Wolfgang Bangerth @ 2002-11-08 12:06 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c++/8500; it has been noted by GNATS.
From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: "Harald H. Soleng" <Harald.Soleng@nr.no>
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/8500: Allows cast to private base class
Date: Fri, 8 Nov 2002 14:03:20 -0600 (CST)
> You should not get an error with old style c-casting.
> However, with
>
> Base* b1 = static_cast<Base*> d1;
>
> on the second line of main you should. Here is the error message from
> the native Sun CC compiler:
> "Error: Using static_cast to convert from Derived* to Base* not allowed."
Uhm, I don't think you can work around access control rules just by using
a C-style cast over a static_cast, can you?
Regards
W.
-------------------------------------------------------------------------
Wolfgang Bangerth email: bangerth@ticam.utexas.edu
www: http://www.ticam.utexas.edu/~bangerth
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: c++/8500: Allows cast to private base class
@ 2002-11-08 7:02 bangerth
0 siblings, 0 replies; 4+ messages in thread
From: bangerth @ 2002-11-08 7:02 UTC (permalink / raw)
To: Harald.Soleng, gcc-bugs, gcc-prs, nobody
Synopsis: Allows cast to private base class
State-Changed-From-To: analyzed->closed
State-Changed-By: bangerth
State-Changed-When: Fri Nov 8 07:02:18 2002
State-Changed-Why:
I think this is actually a duplicate of c++/2330.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8500
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: c++/8500: Allows cast to private base class
@ 2002-11-08 6:58 bangerth
0 siblings, 0 replies; 4+ messages in thread
From: bangerth @ 2002-11-08 6:58 UTC (permalink / raw)
To: Harald.Soleng, gcc-bugs, gcc-prs, nobody
Synopsis: Allows cast to private base class
State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Fri Nov 8 06:58:52 2002
State-Changed-Why:
Confirmed. Reduced code looks like this:
------------------------------
class Base {};
class Derived : private Base {
public:
Derived () : Base() {}
};
int main(void) {
Derived* d1 = new Derived;
Base* b1 = (Base*) d1;
}
----------------------------------
Note that we get indeed an error if the cast (Base*) is
removed, but not with it.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8500
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-11-11 12:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-11 4:16 c++/8500: Allows cast to private base class Gabriel Dos Reis
-- strict thread matches above, loose matches on Subject: below --
2002-11-08 12:06 Wolfgang Bangerth
2002-11-08 7:02 bangerth
2002-11-08 6:58 bangerth
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).