carbon-lang
carbon-lang copied to clipboard
integer overflow in explorer
package P api;
fn Main() -> i32 { var count: i32 = 5; while (not (count == 0)) { count = count - 112722749; } return 0; }
$ bazel run explorer:explorer /tmp/crash.carbon ... interpreter.cpp:172:69: runtime error: signed integer overflow: -2141732226 - 112722749 cannot be represented in type 'int'
Not sure whether this should be caught and reported as a program error or left as is.
I think explorer should be catching this and reporting it as a runtime error, rather than leaving it to ubsan to diagnose.
Thanks.
Relevant Discord discussion -- https://discord.com/channels/655572317891461132/763516049710120960/982378627968675930 One of recommendations was to look into llvm's APInt -- https://llvm.org/doxygen/classllvm_1_1APInt.html
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please comment or remove the inactive label. The long term label can also be added for issues which are expected to take time.
This issue is labeled inactive because the last activity was over 90 days ago.
The current explorer catches this as a runtime error
RUNTIME ERROR: /home/guille/test.carbon:6: integer overflow
I guess this issue can be closed now.
Yeah, looks like #2737 fixed this.