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

Cannot have vector of enum values for enums that do not contain 0 [C++, HEAD] #5284

Closed
T045T opened this issue Apr 11, 2019 · 2 comments
Closed

Comments

@T045T
Copy link
Contributor

T045T commented Apr 11, 2019

For vectors of enum values, the default value seems to be 0 (as in nullptr).
If the vector is of an enum type that does not have 0 in it, flatc refuses to compile the file:

test.fbs:

enum Color : byte { Red = 1, Green, Blue }
table Colors {
  color_values:[Color];
}
$ flatc -c test.fbs
>>> error: path/to/test.fbs:3: 23: error: default value of 0 for field color_values is not part of enum Color

Looks like idl_parser.cpp:682 triggers here, even though it shouldn't.

Without knowing too much about the code, would adding IsScalar(type.base_type) to the guards on that block fix this?

@vglavnyy
Copy link
Contributor

Thank you for the report.
Better check that type.base_type is not a vector.
Duplication #5108.
Will be fixed by #5265.

@T045T
Copy link
Contributor Author

T045T commented Apr 12, 2019

Ah, thanks, I glanced over #5108 because the title looked like it referred to a plain enum value, not a vector of them. Great that's getting fixed!

@T045T T045T closed this as completed Apr 12, 2019
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

No branches or pull requests

2 participants