<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - The constructor of C++ class is called twice when C++ object is an instance of Objective-C class."
   href="http://llvm.org/bugs/show_bug.cgi?id=16198">16198</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>The constructor of C++ class is called twice when C++ object is an instance of Objective-C class.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>konevaanna2012@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I have installed the latest version of Xcode 4.6.2. And when I use the compiler
Apple LLVM 4.2, I get a strange thing. Imagine we have this code sample code,
displayed below.

main.mm:

#import <Foundation/Foundation.h>
#import "ObjCClass.h"

int main(int argc, const char * argv[])
{
    ObjCClass *obj = [[ObjCClass alloc]init];

    [obj SomeObjCMethod];

    [obj release];

    return 0;
}



ObjCClass.h:

#import <Foundation/Foundation.h>
#include "CppClass.h"

@interface ObjCClass : NSObject
{
    CppClass cppClass;
}
- (id)init;
- (void)SomeObjCMethod;
@end


ObjCClass.mm:

#import "ObjCClass.h"

@implementation ObjCClass

- (id)init
{
    self = [super init];
    if (self != nil)
    {

    }
    return self;
}

- (void)SomeObjCMethod
{
    cppClass.someMethod(43);
}




CppClass.h:

class CppClass
{
public:
    CppClass();
    int someMethod(int param);
};


CppClass.cpp:

#include "CppClass.h"
#include <iostream>

using namespace std;

CppClass::CppClass()
{  

}

int CppClass::someMethod(int param)
{
    cout << "param = " << param << endl;
    return param;
}

When I run a program I see in a debugger that the constructor of C++ class
CppClass::CppClas is called twice for some reason. Could you, please, tell me,
is it a bug or maybe I don't understand anything? By the way, when I use GCC
with checkbox "Call C++ Default Ctors/Dtors in Objective-C" being checked this
constructor is called only once...

Regards,
Anna.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>