Skip to content

Specify that the size of an array must be a local compile-time known value - #1416

Open
shyukahn wants to merge 1 commit into
p4lang:mainfrom
shyukahn:array-size-lctk
Open

Specify that the size of an array must be a local compile-time known value#1416
shyukahn wants to merge 1 commit into
p4lang:mainfrom
shyukahn:array-size-lctk

Conversation

@shyukahn

@shyukahn shyukahn commented Jul 3, 2026

Copy link
Copy Markdown

The spec currently states that the size of an array is a compile-time known value, but not local. On the other hand, the size of a header stack must be a local compile-time known value, according to the spec. This PR revises the spec to specify that the size of array must also be a local compile-time known value.

For reference, p4c disallows arrays with a non-local compile-time known value, e.g.

control proto();
package top(proto p);

control c()(bit<8> n) {
    apply {
        bit<32>[n] arr;
    }
}

top(c(2)) main;

yields an error:

array.p4(6): [--Werror=type-error] error: bit<32>[?]: Size of header stack type should be a constant
        bit<32>[n] arr;
        ^^^^^^^^^^

…value

Signed-off-by: Sehyuk Ahn <shyukahn@gmail.com>
@shyukahn shyukahn changed the title Specify that the size of an array must be a local comiple-time known value Specify that the size of an array must be a local compile-time known value Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant