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

Not optimized codegen with NonZeroI32 #69279

Closed
crlf0710 opened this issue Feb 19, 2020 · 2 comments
Closed

Not optimized codegen with NonZeroI32 #69279

crlf0710 opened this issue Feb 19, 2020 · 2 comments
Labels
C-bug Category: This is a bug.

Comments

@crlf0710
Copy link
Member

This code:

use std::num::NonZeroI32;

pub fn div(a: i16, b: NonZeroI32) -> (i32, i32) {
    let a = a as i32;
    let b = b.get();
    (a / b, a % b)
}

should have no possibility of panicking by "divide by zero", however, it seems related check and panicking code is still generated.

@crlf0710 crlf0710 added the C-bug Category: This is a bug. label Feb 19, 2020
@uenoku
Copy link

uenoku commented Feb 19, 2020

It is a longstanding problem: #49572

@jonas-schievink
Copy link
Contributor

Closing in favor of #49572

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants