Skip to content

Conversation

@aferrero2707
Copy link
Collaborator

The EnumFlags fails to compile when the underlying enum has 30 or more elements.

With exactly 32 elements the compilation error is the following:

  note: shift count 32 >= width of type 'int' (32 bits)
   static constexpr auto MaxRep{((1 << (Max_u_v - Min_u_v + 1)) - 1) << Min_u_v}; // largest representable value

With 30 or 31 elements the compilation error is:

  note: value -2147483649 is outside the range of representable values of type 'int'
   static constexpr auto MaxRep{((1 << (Max_u_v - Min_u_v + 1)) - 1) << Min_u_v}; // largest representable value

The solution consists in casting to unint64_t the first "1" in the MaxRep expression, such that the bit shifts are performed on a 64-bit variable.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 4, 2025

REQUEST FOR PRODUCTION RELEASES:
To request your PR to be included in production software, please add the corresponding labels called "async-" to your PR. Add the labels directly (if you have the permissions) or add a comment of the form (note that labels are separated by a ",")

+async-label <label1>, <label2>, !<label3> ...

This will add <label1> and <label2> and removes <label3>.

The following labels are available
async-2023-pbpb-apass4
async-2023-pp-apass4
async-2024-pp-apass1
async-2022-pp-apass7
async-2024-pp-cpass0
async-2024-PbPb-apass1
async-2024-ppRef-apass1
async-2024-PbPb-apass2
async-2023-PbPb-apass5

@aferrero2707
Copy link
Collaborator Author

@f3sch could you please have a look at the proposed change? I could not figure out any side effect, but I am not really an expert of this part of the code.

I would need this PR to be able to use the EnumFlags to handle the RCT selection flags in O2Physics, where we have an enum with 32 elements (one for each of the 32 bits in the RCT mask).

Thanks!

@f3sch
Copy link
Collaborator

f3sch commented Sep 4, 2025

send suggestions via private channel.

The EnumFlags fails to compile when the underlying enum has 30 or more elements.

With exactly 32 elements the compilation error is the following:

  note: shift count 32 >= width of type 'int' (32 bits)
   static constexpr auto MaxRep{((1 << (Max_u_v - Min_u_v + 1)) - 1) << Min_u_v}; // largest representable value

With 30 or 31 elements the compilation error is:

  note: value -2147483649 is outside the range of representable values of type 'int'
   static constexpr auto MaxRep{((1 << (Max_u_v - Min_u_v + 1)) - 1) << Min_u_v}; // largest representable value

The solution consists in using "1ULL" literals in the MaxRep expression, such that the bit shifts are
performed on a variable with at least 64-bits.
@aferrero2707
Copy link
Collaborator Author

@f3sch could you please check the updated commit? Thanks!

@f3sch
Copy link
Collaborator

f3sch commented Sep 4, 2025

@aferrero2707 did it change from what I sent you?

@aferrero2707
Copy link
Collaborator Author

No, a priori is exactly your patch...

@f3sch
Copy link
Collaborator

f3sch commented Sep 4, 2025

ah, ok :)
Thanks again for finding this.

LGTM!

@aferrero2707
Copy link
Collaborator Author

@sawenzel all CIs are green... would you have the time to have a look? This PR is needed to finalise some work on the RTC selection flags in O2Physics. Thanks!

@sawenzel sawenzel merged commit 7d68370 into AliceO2Group:dev Sep 5, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants