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

[BUG] [stdlib] [SIMD] Inconsistent int casting #3167

Closed
martinvuyk opened this issue Jul 2, 2024 · 2 comments
Closed

[BUG] [stdlib] [SIMD] Inconsistent int casting #3167

martinvuyk opened this issue Jul 2, 2024 · 2 comments
Labels
bug Something isn't working mojo-repo Tag all issues with this label

Comments

@martinvuyk
Copy link
Contributor

Bug description

fn main() raises:
    var n1: Int = 255
    var n2: UInt8 = 255
    print(n1 - n2)
    print(int(n1 - n2))
    print(n1 - int(n2))

output:

0
0
256

Steps to reproduce

I think it makes more sense to assume int(UIntX) means positive value, and also when doing UIntX.cast[DType.intX](). Since for example:

fn main() raises:
    var n: UInt8 = 255
    print(int(n))
    print(n.cast[DType.int64]())
    print(n.cast[DType.int32]())
    print(n.cast[DType.int16]())
    print(n.cast[DType.int8]())

output:

-1
255
255
255
-1

only in the case of UInt8 -> Int8 does it really make sense to say it has to be negative since it overflows

System information

- What OS did you do install Mojo on ?
- Provide version information for Mojo by pasting the output of `mojo -v`
- Provide Modular CLI version by pasting the output of `modular -v`
@martinvuyk martinvuyk added bug Something isn't working mojo-repo Tag all issues with this label labels Jul 2, 2024
@DWSimmons
Copy link

#3065
#3146

Not sure why in 3146 there is a cast at all - which is the real bug for that - but the bug presents itself there too

@martinvuyk
Copy link
Contributor Author

thanks a lot for pointing me to the issue #3065 seems like this is a dup of that

Not sure why in 3146 there is a cast at all - which is the real bug for that - but the bug presents itself there too

yeah there are several things going on with SIMD atm. that are weirdly implicit and unexpected

@martinvuyk martinvuyk closed this as not planned Won't fix, can't repro, duplicate, stale Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

2 participants