-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
default value of 0 for field is not part of enum #5108
Comments
I have reproduced this error on the HEAD of the master. if (type.enum_def && IsScalar(type.base_type) && !struct_def.fixed &&
!type.enum_def->attributes.Lookup("bit_flags") &&
!type.enum_def->ReverseLookup(
static_cast<int>(StringToInt(field->value.constant.c_str()))))
Warning("enum " + type.enum_def->name +
" does not have a declaration for this field\'s default of " +
field->value.constant); Since f431a96 (idl_parser.cpp 656-663): if (type.enum_def &&
!type.enum_def->is_union &&
!type.enum_def->attributes.Lookup("bit_flags") &&
!type.enum_def->ReverseLookup(static_cast<int>(
StringToInt(field->value.constant.c_str())))) {
return Error("default value of " + field->value.constant + " for field " +
name + " is not part of enum " + type.enum_def->name);
} Checking |
Hah, didn't spot that, those definitely should be in there. Either of you care to fix it? |
@zplzpl Can you fix it and add a test for this case? |
- new tests - fix google#5108
- hide the implementation of enums from code generators - fix uint64 the issue in the cpp-generator - fix google#5108 - fix issues in cpp code-generator - new tests - add monster_enum.fbs for checking of the cpp code generator
- hide the implementation of enums from code generators - fix uint64 the issue in the cpp-generator - fix google#5108 - fix issues in cpp code-generator - new tests - add monster_enum.fbs for checking of the cpp code generator
- hide the implementation of enums from code generators - fix uint64 the issue in the cpp-generator - fix google#5108 - fix issues in cpp code-generator - new tests - add monster_enum.fbs for checking of the cpp code generator
- hide the implementation of enums from code generators - fix uint64 the issue in the cpp-generator - fix google#5108 - fix issues in cpp code-generator - new tests - add monster_enum.fbs for checking of the cpp code generator - enums with bit_flags attribute should be unsigned
- hide the implementation of enums from code generators - fix uint64 the issue in the cpp-generator - fix google#5108 - fix issues in cpp code-generator - new tests - enums with bit_flags attribute should be unsigned
- hide the implementation of enums from code generators - fix uint64 the issue in the cpp-generator - fix google#5108 - fix issues in cpp code-generator - new tests - enums with bit_flags attribute should be unsigned
- hide the implementation of enums from code generators - fix uint64 the issue in the cpp-generator - fix google#5108 - new tests - enums with bit_flags attribute should be unsigned
- hide the implementation of enums from code generators - fix uint64 the issue in the cpp-generator - fix google#5108 - new tests - enums with bit_flags attribute should be unsigned
- hide the implementation of enums from code generators - fix uint64 the issue in the cpp-generator - fix google#5108 - new tests - enums with bit_flags attribute should be unsigned
- hide the implementation of enums from code generators - fix uint64 the issue in the cpp-generator - fix google#5108 - new tests - enums with bit_flags attribute should be unsigned
I can still reproduce this with latest master, e.g. by compiling the following:
Edit: Never mind, this isn't quite the same issue. It looks like a default must always be provided for fields with an enum type where the enum doesn't contain 0. An attribute to specify a default for that case might be useful, but I'm not sure how much work that would be to implement. |
@precisionconage you are right. |
Some sensitive data has been modified.
On the flatc.exe 1.5.0 version, it works fine.
How should I fix it?
The text was updated successfully, but these errors were encountered: