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

Question on side-effect ordering #2205

Closed
fruffy opened this issue Feb 20, 2020 · 2 comments
Closed

Question on side-effect ordering #2205

fruffy opened this issue Feb 20, 2020 · 2 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 20, 2020

I have the following program snippet:

bit<8> do_something(inout bit<8> some_input) {
    some_input = 8w1;
    return 8w1;
}
control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) {
    bit<8> val;
    apply {
        val = 8w3;
        h.h.a = val + do_something(val);
    }
}

which is turned into

bit<8> do_something(inout bit<8> some_input) {
    some_input = 8w1;
    return 8w1;
}
control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) {
    bit<8> val;
    bit<8> tmp;
    bit<8> tmp_0;
    apply {
        val = 8w3;
        {
            tmp = do_something(val);
            tmp_0 = val + tmp;
            h.h.a = tmp_0;
        }
    }
}

after side-effect ordering.
From my understanding of the spec, expressions should be evaluated from left to right, i.e. the value of val must be saved before calling do_something. However here, val is evaluated after calling do_something, which would violate my assumption.

Is this transformation correct?

side_effect_ordering.p4.txt
side_effect_ordering.stf.txt

@mihaibudiu mihaibudiu added the bug This behavior is unintended and should be fixed. label Feb 24, 2020
@mihaibudiu mihaibudiu self-assigned this Feb 24, 2020
@fruffy
Copy link
Collaborator Author

fruffy commented Apr 21, 2020

For completeness sake, another instance of this issue:

2205b.p4.txt
2205b.stf.txt

@mihaibudiu mihaibudiu added the fixed This topic is considered to be fixed. label May 1, 2020
@fruffy
Copy link
Collaborator Author

fruffy commented May 20, 2020

This has been fixed by #2352.

@fruffy fruffy closed this as completed May 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