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
I encountered an issue with CycloneDDS where enum values outside the defined range are not enforced at runtime. Below is the IDL and the code snippet that demonstrates the problem (I used the HelloWorld example and modified it slightly):
IDL:
module SimpleEnum
{
@bit_bound(32)
enum MySimpleEnum
{
@value(5) A,
@value(12345) B,
@value(2) C
};
struct Data
{
long firstVal;
long secondVal;
MySimpleEnum e;
};
};
Publisher Side:
SimpleEnum_Data msgEnum;
...
msgEnum.e = 38; // Assigning a value outside the defined enum range
...
The IDE (VS) correctly warns that the value 38 is out of range for MySimpleEnum. However, the code compiles and runs without any errors, and the publisher successfully publishes the value 38. I think this behavior is unwanted as it allows invalid enum values to be used, potentially leading to unexpected behavior in the application.
The text was updated successfully, but these errors were encountered:
The current implementation for the enum type in the serializer only checks for the maximum value, which is a known limitation identified when adding extensions for enum support in #1149.
To add proper validation for enum values in the serializer, a list of allowed values would need to be included in the parameter list of the serializer VM opcode, taking into account that enum types can be appendable. Additional changes would also be necessary to handle cases where an enum is used within a (bounded) sequence, union, or array.
Extending the serializer for this is currently not planned, but any contributions toward this improvement would be highly appreciated!
I encountered an issue with CycloneDDS where enum values outside the defined range are not enforced at runtime. Below is the IDL and the code snippet that demonstrates the problem (I used the HelloWorld example and modified it slightly):
IDL:
Publisher Side:
The IDE (VS) correctly warns that the value 38 is out of range for MySimpleEnum. However, the code compiles and runs without any errors, and the publisher successfully publishes the value 38. I think this behavior is unwanted as it allows invalid enum values to be used, potentially leading to unexpected behavior in the application.
The text was updated successfully, but these errors were encountered: