You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As far as I understand about p4c, p4c generally disallows variable and function shadowing within the same namespace as in the spirit of C/C++. (i.e., it disallows duplicate declarations)
However, issue3699.p4 is accepted by the p4c frontend as valid.
voidf1(inh[(max |+| max) == max ? 1 : -1] a){}
voidf1(inh[(max |+| 0) == max ? 1 : -1] a){}
voidf1(inh[value1 == max ? 1 : -1] a){}
It is a bit odd because, first, function f1 is not overloaded. The three declarations have identical parameter arity and parameter names, so they are identical function declarations modulo overloading.
Second, while this is allowed, duplicate declaration of variables or actions are disallowed by p4c. e.g.,
constbit<32> c = 1;
constbit<32> c = 1; // rejected
actiona() {}
actiona() {} // rejected
Is this behavior, of allowing duplicate declaration of functions intended in p4c?
The text was updated successfully, but these errors were encountered:
fruffy
added
the
p4-spec
Topics related to the P4 specification (https://github.com/p4lang/p4-spec/).
label
Jan 12, 2025
As far as I understand about p4c, p4c generally disallows variable and function shadowing within the same namespace as in the spirit of C/C++. (i.e., it disallows duplicate declarations)
However,
issue3699.p4
is accepted by the p4c frontend as valid.It is a bit odd because, first, function
f1
is not overloaded. The three declarations have identical parameter arity and parameter names, so they are identical function declarations modulo overloading.Second, while this is allowed, duplicate declaration of variables or actions are disallowed by p4c. e.g.,
Is this behavior, of allowing duplicate declaration of functions intended in p4c?
The text was updated successfully, but these errors were encountered: