This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/12226] [3.3 Regression] g++ fails to enforce accessibility requirement for copy constructor


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]