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
After FrontEnd_6_ConstantFolding this evaluates to false.
The compiler naturally also gives a warning:
bugs/negative_equality.p4(30): [--Wwarn=mismatch] warning: -1: negative value with unsigned type
if (8w255 == -1) {
I assumed this equality would evaluate to true since both expressions are 8w255 after the implicit cast. Unless such a comparison always evaluates to false, regardless of value, because of the type mismatch. I was digging through the constantFolding.cpp code and saw that the result is evaluate before the cast: https://github.com/p4lang/p4c/blob/master/frontends/common/constantFolding.cpp#L419
Is this intentional?
So I am a little bit confused on how to treat the following expression:
Is this true, false, or undefined?
After
FrontEnd_6_ConstantFolding
this evaluates to false.The compiler naturally also gives a warning:
I assumed this equality would evaluate to true since both expressions are 8w255 after the implicit cast. Unless such a comparison always evaluates to false, regardless of value, because of the type mismatch. I was digging through the
constantFolding.cpp
code and saw that the result is evaluate before the cast: https://github.com/p4lang/p4c/blob/master/frontends/common/constantFolding.cpp#L419Is this intentional?
negative_equality.p4.txt
negative_equality.stf.txt
The text was updated successfully, but these errors were encountered: