This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/3471] gcc 3.01 reports error about a private copy constructor that shouldn't get called.
- From: "austern at apple dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Sep 2003 18:00:16 -0000
- Subject: [Bug c++/3471] gcc 3.01 reports error about a private copy constructor that shouldn't get called.
- References: <20010628221601.3471.ericp@mit.edu>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3471
------- Additional Comments From austern at apple dot com 2003-09-09 18:00 -------
I believe that this resolution is incorrect. f.test(b) initializes a reference of type const foo&
with a temporary, where the temporary was created via a user-defined conversion from
bar, foo::foo(bar). The last bullet item in section 8.5.3/p5 of the standard (i.e. the bullet
item just before par 6) says that the temporary is created "using the rules for a non-
reference copy initialization (8.5)". 8.5p14 says that non-reference copy initialization is
done as if by doing a user-defined conversion and then making a copy. It says that an
implementation is permitted to elide the copy constructor, referring to clause 12.2 for
details. 12.2 paragraph 1 makes it clear that even when the copy constructor is elided,
the implementation is still required to check it for accessibility.
I've opened new bug http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12226 for the failure to
check copy constructor accessibility when the copy constructor is optimized away.