This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13478] [3.3/3.4 Regression] gcc uses wrong constructor to initialize a const reference
- From: "giovannibajo at libero dot it" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Jan 2004 12:24:54 -0000
- Subject: [Bug c++/13478] [3.3/3.4 Regression] gcc uses wrong constructor to initialize a const reference
- References: <20031223143303.13478.erich_guenther@hotmail.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From giovannibajo at libero dot it 2004-01-11 12:24 -------
Ok. Given:
------------------------------------
struct A {};
struct B : protected A {
B() {};
B(const A& ) {};
private:
B(const B& ) {};
};
void foo(const A* ap)
{
const B& br = *ap;
}
------------------------------------
The code should compile, because it should call B(const A&) to construct the
temporary which is then bound to the const reference. Instead, GCC seems to
call B(const B&), which is private. I can't test on 3.0/3.1, but it's surely a
regression since 3.0.4, and can be made a wrong-code one if we make the
constructor public. I keep it as rejects-valid as it's easier to debug.
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |giovannibajo at libero dot
| |it
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |rejects-valid
Last reconfirmed|0000-00-00 00:00:00 |2004-01-11 12:24:53
date| |
Summary|gcc uses wrong constructor |[3.3/3.4 Regression] gcc
|to initialize a const |uses wrong constructor to
|reference |initialize a const reference
Target Milestone|--- |3.4.0
Version|3.3 |3.4.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13478