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

Skip to content

C: Bug in ListConcat and ListSection #2223

Closed
@ubaidsk

Description

@ubaidsk

Bug in ListConcat:

$ cat examples/expr2.py 
from lpython import i32

def test_list_concat():
    t1: list[i32]
    t1 = [2] + [3]
    print(t1)

test_list_concat()
$ python examples/expr2.py 
[2, 3]
$ lpython examples/expr2.py
[2, 3]
$ lpython examples/expr2.py --backend c
expr2__tmp__generated__.c:43:27: error: expected expression
    list_deepcopy_i32(    struct list_i32 constname0;
                          ^
1 error generated.
The command 'gcc -o expr2.out expr2__tmp__generated__.c  -I /Users/ubaid/Desktop/OpenSource/orig_lpython/src/bin/../libasr/runtime -L"/Users/ubaid/Desktop/OpenSource/orig_lpython/src/bin/../runtime" -Wl,-rpath,"/Users/ubaid/Desktop/OpenSource/orig_lpython/src/bin/../runtime" -llpython_runtime -lm' failed.

Bug in ListSection:

$ cat examples/expr2.py            
from lpython import i32

def test_list_section():
    x: list[i32]
    x = [5, -6, 7, -1, 2, 10, -8, 15]
    print(len(x[1:4]))

test_list_section()
$ python examples/expr2.py            
3
$ lpython examples/expr2.py            
3
$ lpython examples/expr2.py --backend c
expr2__tmp__generated__.c:57:33: error: member reference type 'struct list_i32 *' is a pointer; did you mean to use '->'?
    printf("%d\n", * constname01.current_end_point);
                     ~~~~~~~~~~~^
                                ->
expr2__tmp__generated__.c:57:20: error: indirection requires pointer operand ('int32_t' (aka 'int') invalid)
    printf("%d\n", * constname01.current_end_point);
                   ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.
The command 'gcc -o expr2.out expr2__tmp__generated__.c  -I /Users/ubaid/Desktop/OpenSource/orig_lpython/src/bin/../libasr/runtime -L"/Users/ubaid/Desktop/OpenSource/orig_lpython/src/bin/../runtime" -Wl,-rpath,"/Users/ubaid/Desktop/OpenSource/orig_lpython/src/bin/../runtime" -llpython_runtime -lm' failed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cLabel for C language related changes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions