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

Wrong type for logical comparison in C backend #2708

Open
hankluo6 opened this issue May 17, 2024 · 0 comments
Open

Wrong type for logical comparison in C backend #2708

hankluo6 opened this issue May 17, 2024 · 0 comments

Comments

@hankluo6
Copy link
Contributor

hankluo6 commented May 17, 2024

def main0():
    s_var1: str = "Hello"
    s_var2: str = "LPython"

    print(s_var1 or s_var2)

(lp) hank@MacBook-Pro lpython % ./src/bin/lpython test.py --backend=c
expr2__tmp__generated__.c: In function ‘main0’:
expr2__tmp__generated__.c:21:14: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat=]
   21 |     printf("%s\n", s_var1 || s_var2);
      |             ~^     ~~~~~~~~~~~~~~~~
      |              |            |
      |              char *       int
      |             %d
Segmentation fault

The problem might be because the type for BoolOp is character rather than int.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant