-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
False positive warning from dereference-assignment of const pointer to mutable data #77321
Labels
A-lint
Area: Lints (warnings about flaws in source code) such as unused_mut.
C-bug
Category: This is a bug.
D-incorrect
Diagnostics: A diagnostic that is giving misleading or incorrect information.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
nic-hartley
changed the title
dereference-assign with const VAR: *mut u32 causes false positive warning
const VAR: *mut u32; *VAR = 1 causes false positive warning
Sep 29, 2020
nic-hartley
changed the title
const VAR: *mut u32; *VAR = 1 causes false positive warning
Dereferenced assignment with const pointer to mutable data causes false positive warning
Sep 29, 2020
There's a... fine, I guess, workaround of |
nic-hartley
changed the title
Dereferenced assignment with const pointer to mutable data causes false positive warning
False positive warning from dereference-assignment of const pointer to mutable data
Sep 29, 2020
jyn514
added
A-lint
Area: Lints (warnings about flaws in source code) such as unused_mut.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
Sep 29, 2020
cc @Aaron1011 |
@nic-hartley This will be fixed by #77324 |
@Aaron1011 Awesome, thanks so much! |
camelid
added
the
D-incorrect
Diagnostics: A diagnostic that is giving misleading or incorrect information.
label
Sep 30, 2020
Dylan-DPC-zz
pushed a commit
to Dylan-DPC-zz/rust
that referenced
this issue
Sep 30, 2020
…tr, r=petrochenkov Don't fire `const_item_mutation` lint on writes through a pointer Fixes rust-lang#77321
Dylan-DPC-zz
pushed a commit
to Dylan-DPC-zz/rust
that referenced
this issue
Oct 1, 2020
…tr, r=petrochenkov Don't fire `const_item_mutation` lint on writes through a pointer Fixes rust-lang#77321
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-lint
Area: Lints (warnings about flaws in source code) such as unused_mut.
C-bug
Category: This is a bug.
D-incorrect
Diagnostics: A diagnostic that is giving misleading or incorrect information.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I have quite a lot of MMIO in an embedded project, defined and used like this:
(see a playground link)
When I
cargo build
, I'm getting a whole host of warnings of the type:I expect no warnings, because I'm not assigning to a
const
, I'm assigning to a dereferenced*mut u32
, aka a mutable u32.I couldn't figure out a playground example that would show the value actually mutating, but by hitting hardware registers I can prove that the value does get mutated, and it makes sense that it would: The pointer is
const
, but it's pointing to amut
ableu32
. Dereferencing shouldn't care whether the pointer variable isconst
.Meta
rustc --version --verbose
:No backtrace for this bug; it's a warning.
The text was updated successfully, but these errors were encountered: