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++/13478] [3.3/3.4 Regression] gcc uses wrong constructor to initialize a const reference


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


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