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

Assignment removed despite conditional return #2175

Closed
fruffy opened this issue Feb 3, 2020 · 0 comments
Closed

Assignment removed despite conditional return #2175

fruffy opened this issue Feb 3, 2020 · 0 comments
Assignees
Labels
bug This behavior is unintended and should be fixed. fixed This topic is considered to be fixed.

Comments

@fruffy
Copy link
Collaborator

fruffy commented Feb 3, 2020

Consider the following function:

void do_something(inout bit<8> val) {
    if (val == 8w0) {
        val = 8w1;
        return;
    }
    val = 8w2;
    return;
}

After FrontEnd_32_SimplifyDefUse this is turned into

void do_something(inout bit<8> val) {
    if (val == 8w0) {
        ;
        return;
    }
    val = 8w2;
    return;
}

It seems that SimplifyDefUse does not consider the return statement and erroneously removes the assignment.

return_in_function_if.p4.txt
return_in_function_if.stf.txt

@fruffy fruffy changed the title Return in function removes assignment Assignment removed despite conditional return Feb 3, 2020
@mihaibudiu mihaibudiu added the bug This behavior is unintended and should be fixed. label Feb 4, 2020
@mihaibudiu mihaibudiu self-assigned this Feb 4, 2020
mihaibudiu pushed a commit to mihaibudiu/p4c-clone that referenced this issue Feb 7, 2020
mihaibudiu pushed a commit to mihaibudiu/p4c-clone that referenced this issue Feb 12, 2020
@mihaibudiu mihaibudiu added the fixed This topic is considered to be fixed. label Feb 12, 2020
mihaibudiu pushed a commit to mihaibudiu/p4c-clone that referenced this issue Mar 18, 2020
mihaibudiu pushed a commit to mihaibudiu/p4c-clone that referenced this issue Mar 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This behavior is unintended and should be fixed. fixed This topic is considered to be fixed.
Projects
None yet
Development

No branches or pull requests

2 participants