[LLVMbugs] [Bug 10578] New: C++ compiler skips parent constructor

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Aug 3 13:11:46 PDT 2011


http://llvm.org/bugs/show_bug.cgi?id=10578

           Summary: C++ compiler skips parent constructor
           Product: clang
           Version: 2.8
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: prr at eava.ee
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


If C++ class constructor does not have first level parenthesis, parent class
constructor is not executed.

Repro:
Compile following code with Clang:
/////
class CClass1 {
public:
    CClass1() {
        m_iVal1=1;
    }

    int m_iVal1;  
};

class CClass2 : public CClass1 {
public:
    CClass2()
    try {
        m_iVal2=2;
    } catch(...) {
        throw;
    }

    int m_iVal2;
};

int main (int argc, const char * argv[])
{
    CClass2 *pClass2=new CClass2();
    return pClass2!=0;
}
/////
Expected Results:
CClass1 constructor is called and
pClass2->m_iVal1 is initialized with value 1;

Actual Results:
CClass1 constructor is never called and m_iVal1 remains uninitialized.

Notes:
If CClass2 constructor is rewritten as
CClass2() {
    try {
        m_iVal2=2;
    } catch(...) {
        throw;
    }
}
then CClass1 construtor is called.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list