-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[lint idea] dangerous transmutes #546
Comments
@durka heh :) The only valid transmutes of a |
I would love to see something like this, it's very easy to forget about and have seen it come up a number of times. |
@ubsan I expect running clippy on libstd would trigger more lints than that :) |
also casting a |
Does clippy have access to ask rustc whether a struct has any padding, or On Thu, May 12, 2016 at 11:15 AM, Oliver Schneider <notifications@github.com
|
clippy can ask rustc, at least miri can do it (since a few weeks ago), so clippy should be able to do it, too. |
Add lint `transmute_undefined_repr` Partially implements #3999 and #546 This doesn't consider `enum`s at all right now as those are going to be a pain to deal with. This also allows `#[repr(Rust)]` structs with only one non-zero sized fields. I think those are technically undefined when transmuted. changelog: Add lint `transmute_undefined_repr`
Along the lines of
useless_transmute
, it seems plausible to warn ontransmute::<X, Y>(x)
whereX
andY
aren't both primitive types or marked#[repr(C)]
, since as @ubsan keeps reminding us this is likely to cause UB.The text was updated successfully, but these errors were encountered: