p4c icon indicating copy to clipboard operation
p4c copied to clipboard

default_action checking against action is too strong for (s){} argument

Open apinski-cavium opened this issue 3 years ago • 2 comments

take:

struct s
{
  bit f0;
  bit f1;
}
extern bit ext();
control c()
{
  bit<2> tt;
  action a(in bit v1, in bit v2) { tt = v1++v2; }
  action a1(in s v) { tt = v.f0++v.f1; }
  table t
  {
    actions = { a1((s){ ext(),  ext()}); }
    default_action = a1((s){ ext(), ext()});
  }
  apply {}
}

This is rejected:

test3.p4(21): [--Werror=type-error] error: StructExpression: argument does not match declaration in actions list: cast
    default_action = a1((s){ ext(), ext()});
                        ^^^^^^^^^^^^^^^^^^
test3.p4(20)
    actions = { a1((s){ ext(), ext()}); }
                   ^^^^^^^^^^^^^^^^^^

But they are exactly the same arguments.

apinski-cavium avatar Nov 07 '22 00:11 apinski-cavium

This is related to https://github.com/p4lang/p4c/issues/3671 and https://github.com/p4lang/p4c/issues/3666

apinski-cavium avatar Nov 07 '22 00:11 apinski-cavium

@apinski-cavium Is this issue fixed with the merge of #3675 ?

jfingerh avatar Nov 19 '22 03:11 jfingerh