This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/12226] [3.3 Regression] g++ fails to enforce accessibility requirement for copy constructor
- From: "mark at codesourcery dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 6 Jan 2004 00:48:42 -0000
- Subject: [Bug c++/12226] [3.3 Regression] g++ fails to enforce accessibility requirement for copy constructor
- References: <20030909174601.12226.austern@apple.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From mark at codesourcery dot com 2004-01-06 00:48 -------
Subject: Re: [3.3 Regression] g++ fails to enforce
accessibility requirement for copy constructor
On Mon, 2004-01-05 at 14:52, dbaron at dbaron dot org wrote:
> ------- Additional Comments From dbaron at dbaron dot org 2004-01-05 22:52 -------
> Before I go fix Mozilla to deal with this
> ( http://bugzilla.mozilla.org/show_bug.cgi?id=230118 ), I just want to
> double-check that this change was intended to apply to calls to functions taking
> reference types in addition to initialization of reference variables. That is,
> the program:
>
> class C {
> public: C() {}
> private: C(const C&) {}
> };
>
> void f(const C& c) { }
>
> int main()
> {
> f(C());
> return 0;
> }
>
> now yields an error.
You are correct; that program is invalid. The copy constructor for C
must be accessible at the point that the rvalue is bound to the
reference, even though G++ will optimize away its use.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12226