zfp icon indicating copy to clipboard operation
zfp copied to clipboard

example array.cpp error:C4146 Unary minus operator applied to unsigned type, the result is still unsigned. store.hpp 241

Open Chuan1937 opened this issue 1 year ago • 3 comments

I use cmake build zfp and general example "arraycpp", but when i run it in visual stdio 2022, there's a error: C4146 Unary minus operator applied to unsigned type, the result is still unsigned. It is in store.hpp in 241 rows.I don't know how to fix it.

Chuan1937 avatar Jul 19 '24 12:07 Chuan1937

Nothing to be fixed here--the code is correct and unary negation is perfectly defined for unsigned types. Surely VS is just being overly cautious and giving a warning, not an error, right? And don't be fooled by Microsoft's documentation that suggests "An unsigned value is unchanged by the unary negation operator." That is blatantly false. For example, -(1u) == 0xff...fu.

We might look into suppressing this warning, but it should have no bearing on the correctness of the code.

lindstro avatar Jul 19 '24 13:07 lindstro

thank you, i have finish it.

Chuan1937 avatar Jul 21 '24 14:07 Chuan1937

OK. I'm keeping the issue open for now as we may want to silence these compiler warnings.

lindstro avatar Jul 24 '24 18:07 lindstro