Skip to content
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

Enum-discriminated union with all cases covered in C++11 mapping #1900

Closed
ClaytonCalabrese opened this issue Sep 23, 2020 · 5 comments · Fixed by #1950
Closed

Enum-discriminated union with all cases covered in C++11 mapping #1900

ClaytonCalabrese opened this issue Sep 23, 2020 · 5 comments · Fixed by #1950

Comments

@ClaytonCalabrese
Copy link
Contributor

ClaytonCalabrese commented Sep 23, 2020

Unsure the importance of this but it was something I noticed while doing tryconstruct. I removed all such instances from my c++11 test but the problem is still there.

A seg fault occurs in the idl

my.idl:

enum EnumType {VALUE1, VALUE2};

union NestedUnion switch (EnumType) {
  case VALUE1: boolean u_b;
  case VALUE2: short u_s;
  default: float u_f;
};

console to replicate:
gdb opendds_idl
run -Lc++11 my.idl

the e->value_to_name(dv.u.enum_val) in langmap_generator will be a null causing the segfault.

@mitza-oci
Copy link
Member

The difference between this one and the enum-discriminated unions we've already tested is that the default: branch is not possible to reach given the two other branches already cover all enumerators.

@mitza-oci
Copy link
Member

This is not a valid union according to OMG IDL. Unfortunately TAO_IDL_FE is not rejecting it.

A union type can contain a default label only where the values given in the non-default labels do not cover the entire range of the union's discriminant type.

@jwillemsen
Copy link
Member

It is marked as illegal by ridlc, maybe something to report as issue to TAO_IDL?

IDL::ParseError: 'default' case label superfluous for IDL::AST::Union NestedUnion

@ClaytonCalabrese
Copy link
Contributor Author

enum EnumType {VALUE1, VALUE2};

union NestedUnion switch (EnumType) {
case VALUE1: boolean u_b;
case VALUE2: short u_s;
};

Still causes the seg fault.

@mitza-oci
Copy link
Member

AST_Union::default_value results in a value that's not in the range of the enum. I guess we need to check for that and correct it.

@mitza-oci mitza-oci changed the title Enums do not work as a discriminator in C++11 mapping Enum-discriminated union with all cases covered in C++11 mapping Oct 6, 2020
@mitza-oci mitza-oci linked a pull request Oct 16, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants