Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Chuan1937 opened this issue Jul 19, 2024 · 3 comments

Comments

@Chuan1937
Copy link

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.

@lindstro
Copy link
Member

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.

@Chuan1937
Copy link
Author

thank you, i have finish it.

@lindstro
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants