-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible bug: two_comp_mod has no export_bytes() call #476
Comments
Could it be because the operation actually doesn't change the bit pattern, in which case there would be no need to call export_bytes? |
I have since found that two_comp_mod is exercised by a P4_16 test case in p4lang/p4c named arith5-bmv2.p4, and also a couple of P4_14 programs contain the operator in their bmv2 JSON files. The arith5-bmv2.stf test cases look reasonable to me, so maybe no bug here. When you say "the operation doesn't change the bit pattern", do you mean the output bit pattern is always equal to the input bit pattern? That would have a much shorter implementation in lines of code, wouldn't it? (e.g. "value = src;") |
Discard my original comment, it's incorrect. I thought the operator was doing something else entirely. |
I don't know the implementation details well enough to know whether this is a bug -- was just looking at the source code for two_comp_mod and other operators in behavioral-model code, and noted that all of the methods implementing operators in class Data that return void end with a call to export_bytes(), except two_comp_mod:
https://github.com/p4lang/behavioral-model/blob/master/include/bm/bm_sim/data.h#L317
Here are add and sub, for comparison:
https://github.com/p4lang/behavioral-model/blob/master/include/bm/bm_sim/data.h#L220
I don't have a test case exhibiting wrong behavior here -- just a suspicion that two_comp_mod may have been left behind when others were updated at some point in the past, and it may not be exercised in any test cases since it is a relatively rarely used operator (I think only when signed values occur in P4 source code, which is uncommon).
The text was updated successfully, but these errors were encountered: