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

UB program gets wrongly converted #143

Open
trufae opened this issue Sep 4, 2023 · 0 comments
Open

UB program gets wrongly converted #143

trufae opened this issue Sep 4, 2023 · 0 comments
Labels
Bug Something isn't working

Comments

@trufae
Copy link

trufae commented Sep 4, 2023

This program should not even compile, but i tried it for fun because gcc/clang show 0 warnings with -Wall to see how c2v behaved with this code and resulted in some interesting bugs in the transpiler:

int
main ()
{
  char r = -1;
  unsigned s = r;
  unsigned t = (unsigned char)r;
  if (s != -1)
    return 2;
  if (t != 255)
    return 1;
  return 0;
}

is translated to:

[translated]
module main

fn main() {
	r := -1
	s := r
	t := u8(r)
	if s != -1 {
		return
	}
	if t != 255 {
		return
	}
	return
}

Note:

  • No "return" values
  • Missing type/sign casts
@ArtemkaKun ArtemkaKun added the Bug Something isn't working label Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants