Closed peirick closed 4 years ago
That particular line is u32 mask = (u32)-carry; // carry == 0 or 1
. In this case, the error is completely spurious because the behavior this warns about is exactly what the code trying to do:
carry |
mask |
---|---|
0 | 0 == (u32)-0 |
1 | 0xffffffff == (u32)-1 |
There's probably a workaround to be found here other than overriding that particular error for monocypher.c
if possible (something like ((u32)~carry) + 1
maybe? It's likely missing some more casts and/or can be safely simplified in some manner). As far as I'm aware, unary negation of an unsigned integer is well-defined and shouldn't be an error, so this is probably VS2019 being overzealous (or the C++ standard disagreeing with C).
Probably needs @LoupVaillant's attention. Personally, I'd be fine using a workaround and avoiding unsigned negation for scared, but his mileage may vary. Note for Loup: The workaround above compiles under VS2019 without warning for me and appears to work as intended.
The workaround above compiles under VS2019 without warning for me and appears to work as intended.
@fscoto — What about tests with patch under VS2019? Passed, right?
They're in the same state of breakage with and without it, cf. #170.
Hi, thanks for the report. Should work better now.
In file
monocypher.c
line 2684 gives the following error:monocypher.c(2683,27): error C4146: unary minus operator applied to unsigned type, result still unsigned
see also C4146