-
Notifications
You must be signed in to change notification settings - Fork 82
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
Tricky case with uninitialized values... #952
Comments
It looks to me like it is related to this case #891. The compiler is free to reduce this to |
Here is my understanding from version 1.2.1 of the P4_16 language spec. Any call to f() says that its direction It seems to me that if you want to capture the maximum amount of undefined-ness allowed by the spec, the answer to the question hinges on whether (1) If it is, then we do not know what its value is, but it is some legal value of type (2) If there is no assignment to So my belief is that the final state Here are a couple of small variations to the program that seem to allow more kinds of behaviors, though, and they are such small variations that I would not be surprised if most compiler writers would not try to preserve the maximum undefined-ness, and instead make transformations that reduce the number of possible final states. Variant program B:
In variant program B, Variant program C:
In variant program C, This is something I puzzled over earlier when thinking about some other P4_16 corner case, and perhaps we don't want future versions of the spec to have such weird cases in it for such similar programs. Note: I consider all three of these programs to be poor examples of software engineering, and a good P4 compiler and/or lint-like tool should point out the use of uninitialized values. I do not have an example off-hand of a P4_16 program that raises these questions that I would consider safely written, but I don't have any convincing argument that there are no such programs. The closest thing I can think of there would be using one or more fields in an invalid header as a table key field, but there the language spec has some explicit words that if you attempt to match such a value as a ternary field, it should always predictably match a ternary table entry where that field is completely wildcard in all bit positions. See a mention of "ternary" in Section 8.22. "Reading uninitialized values and writing fields of invalid headers". |
Edit: Actually, taking a closer look: The copy semantics are preserved, a second variable is introduced. So there is no issue in this case. |
In the interest of tidying up the set of active issues on the P4 specification repository, I'm marking this as "stalled" and closing it. Of course, we can always re-open it in the future if there is interest in resurrecting it. |
Consider the following program.
According to the spec, what are the possible final values of
z
afterMyC
is executed?The text was updated successfully, but these errors were encountered: