Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
7680 Discussions

"error : expected an integer constant" for Enum

Ian_Mallett1
Beginner
474 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
474 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.

Kittur_G_Intel
Employee
474 Views

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

_Kittur 

Ian_Mallett1
Beginner
474 Views

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

Kittur_G_Intel
Employee
474 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

Kittur_G_Intel
Employee
474 Views

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

Kittur

Reply