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

Num.powInt overflow behavior #7062

Open
KilianVounckx opened this issue Sep 6, 2024 · 2 comments
Open

Num.powInt overflow behavior #7062

KilianVounckx opened this issue Sep 6, 2024 · 2 comments
Labels
bug Something isn't working dev backend The Development Backends

Comments

@KilianVounckx
Copy link
Contributor

When Num.powInt overflows, it doesn't panic, but silently returns 0.

To replicate, enter Num.powInt (Num.toU8 2) 8 in the repl.

@lukewilliamboswell lukewilliamboswell added bug Something isn't working dev backend The Development Backends labels Sep 10, 2024
@lukewilliamboswell
Copy link
Collaborator

@KilianVounckx can you please check if this is reproducible using the llvm backend. You can copy this into an basic-cli app and run using --optimize. Also can you please confirm which operating system and architecture you experienced this on.

I get the same behaviour on my apple silicon Mac using the repl.

» Num.powInt 2u8 8

0 : U8

I suspect this is related to the dev backend.

@KilianVounckx
Copy link
Contributor Author

@lukewilliamboswell I wrote this sample program:

app [main] {
    cli: platform "https://github.com/roc-lang/basic-cli/releases/download/0.15.0/SlwdbJ-3GR7uBWQo6zlmYWNYOxnvo8r6YABXD-45UOw.tar.br",
}

import cli.Stdout

main : Task {} _
main =
    x : U8
    x = 2
    y = Num.powInt x 8
    Stdout.line! (Num.toStr y)

I again get an output of 0 when building with --optimize and then running the executable.

I am using Pop-OS! on an x86_64 machine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dev backend The Development Backends
Projects
None yet
Development

No branches or pull requests

2 participants