Skip to content

Adding initial test for gruntz #2437

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

Merged
merged 1 commit into from
Dec 4, 2023
Merged

Conversation

anutosh491
Copy link
Collaborator

@anutosh491
Copy link
Collaborator Author

The c backend (c_sym) shows a segmentation fault due to reasons I'm not sure of. Might need to look into it

Copy link
Contributor

@certik certik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this looks good.

@certik certik merged commit 4150db6 into lcompilers:main Dec 4, 2023
@anutosh491 anutosh491 deleted the gruntz_01 branch December 6, 2023 03:41
@anutosh491
Copy link
Collaborator Author

Okay I think this is why the C (c_sym) backend might not be working and we get a Segmentation fault. The C code generated is something like

void mmrv(struct list_CPtr _lpython_return_variable);
void test_mrv1();
void __main__global_stmts();



// Implementations
void mmrv(struct list_CPtr _lpython_return_variable)
{
    struct list_CPtr l;
    struct list_CPtr constname0;
    list_init_CPtr(&constname0, 0);
    constname0.current_end_point = 0;
    list_deepcopy_CPtr(&constname0, &l);

    list_deepcopy_CPtr(&l, &_lpython_return_variable);

}

void test_mrv1()
{
    struct list_CPtr __libasr__created__var__0__func_call_res;
    struct list_CPtr ans;
    mmrv(__libasr__created__var__0__func_call_res);
    list_deepcopy_CPtr(&__libasr__created__var__0__func_call_res, &ans);

    printf("");
    print_list_CPtr_(ans);
    printf("\n");
    ASSERT(ans.current_end_point == 0);
}

What we need is this I suppose

void mmrv(struct list_CPtr* _lpython_return_variable);
void test_mrv1();
void __main__global_stmts();



// Implementations
void mmrv(struct list_CPtr* _lpython_return_variable)
{
    struct list_CPtr l;
    struct list_CPtr constname0;
    list_init_CPtr(&constname0, 0);
    constname0.current_end_point = 0;
    list_deepcopy_CPtr(&constname0, &l);

    list_deepcopy_CPtr(&l, _lpython_return_variable);
    //_lpython_return_variable

}

void test_mrv1()
{
    struct list_CPtr __libasr__created__var__0__func_call_res;
    struct list_CPtr ans;
    mmrv(&__libasr__created__var__0__func_call_res);
    list_deepcopy_CPtr(&__libasr__created__var__0__func_call_res, &ans);

    printf("");
    print_list_CPtr_(ans);
    printf("\n");
    ASSERT(ans.current_end_point == 0);
}

@certik
Copy link
Contributor

certik commented Dec 6, 2023

Yes, I think this approach is good.

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

Successfully merging this pull request may close these issues.

2 participants