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

Negative literals cast to unsigned integers without a warning. #16313

Closed
mahkoh opened this issue Aug 7, 2014 · 2 comments
Closed

Negative literals cast to unsigned integers without a warning. #16313

mahkoh opened this issue Aug 7, 2014 · 2 comments

Comments

@mahkoh
Copy link
Contributor

mahkoh commented Aug 7, 2014

let i: u8 = -1

Replacing -1 by 256 gives the following warning:

 literal out of range for its type

This could also apply to the code above. Unfortunately even an explicit cast to u8 doesn't remove the second warning.

Note that clang has a related warning:

warning: implicit conversion changes signedness: 'int' to 'unsigned int' [-Wsign-conversion]
        unsigned int i = -1;
                     ~   ^~
@Gankra
Copy link
Contributor

Gankra commented Aug 7, 2014

Duplicate of #5477

@mahkoh
Copy link
Contributor Author

mahkoh commented Aug 7, 2014

not warning on this is a feature

So so.

@mahkoh mahkoh closed this as completed Aug 7, 2014
bors added a commit to rust-lang-ci/rust that referenced this issue Jan 15, 2024
minor: Remove newline and add dot in syntax docs

While reading through the docs I came across these two small typos.
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