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: [email protected]
ReportedBy: [email protected]
CC: [email protected], [email protected]
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs