crust
crust copied to clipboard
Wrong output when doing addition on short
#include <iostream>
using namespace std;
int main() {
short a = 32767;
short b = 32767;
int c = a + b;
cout<<c;
}
Current crust will produce something like this
...
fn main ( ) {
...
let mut a : i16 = 32767 ; let mut b : i16 = 32767 ;
let mut c : i32 = a+b ; // ~~> wrong
...
}
Its seems crust don't handle c integer promotion from short to int.
Hi It require you to add cast manually.
Hi @NishanthSpShetty,
Ideally crust
will be automatically handling the cast, I know this issue will be tough to solve in current crust state. It will require some semantic analysis on the C code. However crust will need semantic & flow control analysis if you plan to support goto
@bungcip Yeah..you are correct. Semantic analysis and flow controller analysis required, which may solve lot of issues.