Commit 7d68370
Fix EnumFlags compilation for large enums
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.1 parent f37a28b commit 7d68370
File tree
2 files changed
+50
-2
lines changed- Common/Utils
- include/CommonUtils
- test
2 files changed
+50
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
163 | | - | |
164 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
165 | 166 | | |
166 | 167 | | |
167 | 168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
31 | 71 | | |
32 | 72 | | |
33 | 73 | | |
| |||
257 | 297 | | |
258 | 298 | | |
259 | 299 | | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
260 | 307 | | |
0 commit comments