c2v incorrectly translates `sizeof var_name`
parke opened this issue · 0 comments
parke commented
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