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

"error : expected an integer constant" for Enum

Ian_Mallett1
Beginner
1,078 Views

This C++ code (Windows) will erroneously produce this error:

enum { ALIGN=16 }; __declspec(align(ALIGN)) float arr[4];

Enums are constexprs, so "ALIGN" is definitely a constant.

0 Kudos
5 Replies
Ian_Mallett1
Beginner
1,078 Views

After some playing, it seems that this code works:

enum { ALIGN=16 }; __declspec(align((int)ALIGN)) float arr[4];

According to the standard: "values of unscoped enumeration type are implicitly-convertible to integral types" (i.e., that cast shouldn't be necessary). So this seems to be the underlying issue.

0 Kudos
KitturGanesh
Employee
1,078 Views

Yes, I tried the above case as well and what you mention is correct. Thanks for the confirmation.

_Kittur 

0 Kudos
Ian_Mallett1
Beginner
1,078 Views

This is still broken in 16 update 2. Also broken for `alignas(...)`.

0 Kudos
KitturGanesh
Employee
1,078 Views

That's correct Ian, it's broken in update 2. I'll check and see if this is fixed in the main branch or will be in the upcoming update when it's scheduled. Anyways, I'll go ahead and file an issue on this with the developers. Appreciate your patience through this and will keep you updated accordingly.

Regards,
Kittur

0 Kudos
KitturGanesh
Employee
1,078 Views

Ian, I've filed issue (DPD200410436) and will keep you updated, thx.

Kittur

0 Kudos
Reply