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

Error #409

benoitsevigny
Beginner
882 Views
Before I proceed and upgrade my 4.5 Intel Compiler, I would like to know if the current version still generates an error when compiling the following code:

class foo {
public:
union {
float f;
const int i;
};
inline foo(float x) : f(x) {}
};

With 4.5, the compiler aborts with the following message:

error #409: "foo::foo(float)" provides no initializer for: const member "foo::i"

This class declares an anonymous union containing a const member which is initialized indirectly by the other member. This compiles correctly on both GCC 3.2 and Visual C++ 6.0.

Has this been fixed? Otherwise, any hope it can be?

Regards

Benoit Sevigny
Kaydara Inc.
0 Kudos
1 Reply
Ganesh_R_Intel
Employee
882 Views
This is a 'soft error'. Meaning, we really believe this is an error (as in arguably not good programming practice and outside of the standards definition) but you have the choice to make this a warning.

You can force the compiler to make this a warning by issueing the /Qww option.
/Qww[,,...] changes the severity of diagnostics L1 through LN to warning
You can also convert it into a remark with /Qwwr or disable it with /Qwd.

You can also add this to your system config file (icl.cfg/icl6.cfg in your compiler bin directory. Please see the users guide for additional info on using the config file) to make this a permanent option for all your compiles.

Having said all that, I believe we made this to be a warning by default since version 6.0. So you could just try the latest version.

Hope that helped.

Ganesh
0 Kudos
Reply