Skip to content

Commit 1fe300c

Browse files
authored
Merge pull request #850 from jafingerhut/issue845-local-header-variables-initialized-invalid
Require that local variables with header-like types are initialized i…
2 parents 1a56876 + f3c0cd3 commit 1fe300c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

p4-16/spec/P4-16-spec.mdk

+7-5
Original file line numberDiff line numberDiff line change
@@ -2287,8 +2287,9 @@ one bit long field. This declaration introduces a new identifier in the
22872287
current scope; the type can be referred to using this identifier. A header is
22882288
similar to a `struct` in C, containing all the specified fields. However, in
22892289
addition, a header also contains a hidden Boolean "validity" field. When the
2290-
"validity" bit is `true` we say that the "header is valid". When a header is
2291-
created its "validity" bit is automatically set to `false`. The "validity"
2290+
"validity" bit is `true` we say that the "header is valid". When a local
2291+
variable with a header type is
2292+
declared, its "validity" bit is automatically set to `false`. The "validity"
22922293
bit can be manipulated by using the header methods `isValid()`, `setValid()`,
22932294
and `setInvalid()`, as described in Section [#sec-ops-on-hdrs].
22942295

@@ -4700,9 +4701,10 @@ optInitializer
47004701
;
47014702
~ End P4Grammar
47024703

4703-
Variable declarations without an initializer are uninitialized (except for header
4704-
stacks, which have their `nextIndex` counter initialized to `0`,
4705-
as discussed in [#sec-expr-hs]). The language places few restrictions on
4704+
Variable declarations without an initializer are uninitialized (except for
4705+
headers and other header-related types, which are initialized to invalid in the
4706+
same way as described for direction `out` parameters in Section
4707+
[#sec-calling-convention]). The language places few restrictions on
47064708
the types of the variables: most P4 types that can be written
47074709
explicitly can be used (e.g., base types, `struct`, `header`,
47084710
header stack, `tuple`). However, it is impossible to declare variables with types

0 commit comments

Comments
 (0)