← 输入框|github.com|刷新
Skip to content

Wrong type for logical comparison in C backend #2708

Open

Description

@hankluo6
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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions