Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Intel C++ 2016: Constructor and Destructor in unnamed union will be called.

Gomes_T_
Beginner
723 Views
class Optional{
public:
  union {
    Value m_value; ///< should be uninitialized ! But Intel Compiler will Constructor and Destructor here!
  };
};

Intel C++ 2016 will call Constructor and Destructor for the class inside unnamed union.

But this should be deleted and like VS2015 compiler it would be great to get a message about this.

0 Kudos
6 Replies
Gomes_T_
Beginner
724 Views

Here is VS 2015  compiler message:

destructor was implicitly defined as deleted because a base class destructor is inaccessible or deleted

0 Kudos
JenniferJ
Moderator
724 Views

how is the "Value" type defined? can you post the definition here?

Jennifer

0 Kudos
Gomes_T_
Beginner
723 Views
Thanks for answer. Actually Value can be any type because it was a template parameter. But for testing here is the example: https://gist.github.com/DevO2012/e3e1f011b890e0ae7ff6 This is strange but in this test Destructor will not be called, only Constructor will be called . Any way something is totally broken here.
0 Kudos
JenniferJ
Moderator
723 Views

Ok. Thanks for the full test.

I've just filed a bug DPD200369174 to the C++ Front End team.

Jennifer

0 Kudos
JenniferJ
Moderator
723 Views

An update about this issue. The run-time error that Intel Compiler generated code calls Value's constructor is fixed already. The fix will be in the coming 16.0 beta update 1 release.

As for the diagnostic msg, icl won't emit any just like g++ 4.8 or later. It doesn't make sense to have a "warning" here.

Please watch for the email notification about the update 1 from Intel Premier Support.

thanks,

Jennifer

0 Kudos
Gomes_T_
Beginner
724 Views
Thanks, it appears to be fixed in 16.0 Beta update 1.
0 Kudos
Reply