Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Ian_Mallett1
Beginner
228 Views

"error : expected an integer constant" for Enum

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
228 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
228 Views

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

_Kittur 

Ian_Mallett1
Beginner
228 Views

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

Kittur_G_Intel
Employee
228 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
228 Views

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

Kittur

Reply