Open
Description
Hi,
The following P4 code causes a compilation error, even though it's inside an action block and should be evaluated at runtime:
action flow_control(
ID_t id,
threshold_t threshold,
factor_t factor
) {
threshold_t base_threshold;
base_threshold = threshold * ((threshold_t) factor);
}
}
Compilation error:
/home/p4/P4Sentinel/p4src/ingress.p4(110): [--Werror=invalid] error: threshold * (bit<64>)factor: could not evaluate expression at compilation time
However, if the cast is removed or the expression is split into two lines (i.e., casting to a temp variable), the compiler accepts it. This suggests a possible issue in constant folding or expression analysis during parsing.
Thanks in advance!