Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Wrong type for logical comparison in C backend #2708

Open
@hankluo6

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.

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