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++/26029] New: Member initialization by constructor parameter object method calls


//      Expected output is:
//      i_=1

//      In g++ 3.4.4 under cygwin, output is
//      i_=
//      followed by a random integer value
//      (I've seen zero and 97).
//      It appears as though the i_ member is
//      not being initialized.

#include        <iostream>

struct  B1
{
        B1      (int      i  ): i_(i    ) { }
        B1      (const B1 &b1): i_(b1.i_) { }
        int i_;
};

struct  B2
{
        B2      (void)                    { }
};

struct  Initializer
{
        B1      b1(void)        const   {       return  B1(1);  }
        B2      b2(void)        const   {       return  B2( );  }
};

struct  D       :       public  B1,     public  B2
{
        D       (Initializer init): B1(init.b1()), B2(init.b2()) { }
};

int     main    (void)
{
        Initializer init;
        D           d(init);

        std::cout << "i_=" << d.i_ << std::endl;

        return  0;
}


-- 
           Summary: Member initialization by constructor parameter object
                    method calls
           Product: gcc
           Version: 3.4.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Don at Skyler dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26029


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