-
Notifications
You must be signed in to change notification settings - Fork 445
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
[bug/enhancement] boolean fields #272
Comments
There is no "metadata" in P4-16 really; there are just structs, and they can have boolean fields. The spec forbids boolean fields in headers, and the error message indicates that this is a header. However, the error is a BUG, so it looks like this header was somehow synthesized by the compiler internally. Can you post a some code to reproduce this error, please? |
This is actually easy to reproduce; it happens for a header with a bool field. |
@mbudiu-vmw: I opened an issue in p4-spec as you suggested, see p4lang/p4-spec#123. I cannot think of any good reasons to disallow booleans in header fields, but let's discuss there. |
* Fix for issue #272 * Small documentation fix
@mbudiu-vmw: Actually, it seems that structs cannot have boolean fields. I get the error
when trying to compile #include <core.p4>
#include <v1model.p4>
typedef standard_metadata_t std_meta_t;
struct some_meta_t { bool flag; }
struct H { }
struct M { some_meta_t some_meta; }
control DeparserI(packet_out packet, in H hdr) {
apply { }
}
parser ParserI(packet_in pk, out H hdr, inout M meta, inout std_meta_t std_meta) {
state start { transition accept; }
}
control VerifyChecksumI(in H hdr, inout M meta) {
apply { }
}
control ComputeChecksumI(inout H hdr, inout M meta) {
apply { }
}
control IngressI(inout H hdr, inout M meta, inout std_meta_t std_meta) {
apply { }
}
control EgressI(inout H hdr, inout M meta, inout std_meta_t std_meta) {
apply { }
}
V1Switch(ParserI(), VerifyChecksumI(), IngressI(), EgressI(), ComputeChecksumI(), DeparserI()) main; |
Great, this is fixed 👍 |
Currently, the compiler does not accept boolean metadata, and raises errors such as this one:
This seems like an arbitrary (and in practice, very annoying) restriction. Are there deeper reasons for this or is it just something that hasn't been implemented yet?
Boolean metadata is extremely common in switch.p4. It would be convenient to use
bool
rather thanbit<1>
for this purpose.The text was updated successfully, but these errors were encountered: