Skip to content

Specify behavior of +: slice used as l-value #1390

Description

@pacokwon

The current working draft of the specification does not specify the behavior of +: style slices when they are used as l-values.

Here is the relevant description of +: slices in the specification.

A slice may also be specified as [L+:W] where L is the lowest bit of the slice and W is the width of the slice. In this case, only W must be a non-negative local compile-time known numeric value. L must also be a numeric value and some architectures may require it to be compile-time known. It must also be non-negative and in-range for the type. Some architectures may allow variable indexing, in which case an out of range value will be equivalent to a shift of that amount. An index that is not compile-time known must be a bit type in order to ensure that it is non-negative.

Earlier in the same paragraph in the specification is the behavior of H:L slices used as l-values described as follows:



Slices are also l-values, which means that P4 supports assigning to a slice: e[H:L] = x. The effect of this statement is to set bits H through L (inclusive of both) of e to the bit-pattern represented by x, and leaves all other bits of e unchanged.

Unlike H:L slices, the range referenced by +: could potentially go out of bounds. Hence a clear description of how it behaves in such edge cases also seems necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions