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

c2v incorrectly translates sizeof var_name #161

Closed
parke opened this issue Nov 16, 2023 · 0 comments · Fixed by #169
Closed

c2v incorrectly translates sizeof var_name #161

parke opened this issue Nov 16, 2023 · 0 comments · Fixed by #169
Labels
Bug Something isn't working

Comments

@parke
Copy link

parke commented Nov 16, 2023

In the below program, c2v translates sizeof hello incorrectly.

#include <unistd.h>
int main() {
  char hello[] = "Hello, unistd world!\n";
  write ( 1, hello, sizeof hello );
  return 0; }

I believe that sizeof hello is valid C code. c2v translates it (incorrectly) to sizeofhello.

The actual (incorrect) output:

[translated]
module main

fn main() {
        hello := c'Hello, unistd world!\n'
        C.write(1, hello, sizeofhello)
        return
}

Changing sizeof hello to sizeof(hello) avoids the problem. But, as I said, I believe that sizeof hello is valid C.

For reference:
https://en.cppreference.com/w/c/language/sizeof
https://en.cppreference.com/w/cpp/language/sizeof

@ArtemkaKun ArtemkaKun added the Bug Something isn't working label Nov 16, 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

Successfully merging a pull request may close this issue.

2 participants