-
Notifications
You must be signed in to change notification settings - Fork 752
ir: Avoid generating out-of-range values in constants. #276
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,9 @@ pub const bar: _bindgen_ty_1 = _bindgen_ty_1::bar; | |
#[repr(u32)] | ||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | ||
pub enum _bindgen_ty_1 { foo = 4, bar = 8, } | ||
pub type EasyToOverflow = ::std::os::raw::c_ulonglong; | ||
pub const k: EasyToOverflow = 2147483648; | ||
pub const k_expr: EasyToOverflow = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't seem to be desirable. Build would succeed, but existence of this may lead to weird bug. This should either be removed, or be linked. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're getting zero from clang in this case unfortunately, so there's little I can do :( |
||
pub const BAZ: ::std::os::raw::c_longlong = 24; | ||
pub const fuzz: f64 = 51.; | ||
pub const BAZZ: ::std::os::raw::c_char = 53; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I slightly preferred all this with the slightly more concise method chaining, but either way works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it was a bit trickier to write it that way, because we may be overriding a
Some(value out of range)
withNone
, so I preferred to be more explicit.