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

[C++] flatc generates invalid code for union UnPackTo when "--cpp-field-case-style upper" and "--gen-object-api" are used #8446

Open
Ailuridae opened this issue Dec 11, 2024 · 1 comment

Comments

@Ailuridae
Copy link

The schema below, when compiled with the options --cpp, --gen-object-api and --cpp-field-case-style upper, generates invalid C++ code.

Affecfted versions: v24.3.25, current master

Schema

table MyUnionContent {
  value:uint8;
}

union MyUnion {
  content:MyUnionContent,
}

table MyTable {
  property:MyUnion;
}

Output

// ...

struct MyTableT : public ::flatbuffers::NativeTable {
  typedef MyTable TableType;
  MyUnionUnion Property{};
};

// ...

inline void MyTable::UnPackTo(MyTableT *_o, const ::flatbuffers::resolver_function_t *_resolver) const {
  (void)_o;
  (void)_resolver;
  { auto _e = Property_type(); _o->property.type = _e; }
  { auto _e = Property(); if (_e) _o->Property.value = MyUnionUnion::UnPack(_e, property_type(), _resolver); }
}

// The capitalization of _o->property.type and property_type() is wrong

// ...
@Ailuridae
Copy link
Author

Related: #7210

Ailuridae pushed a commit to Ailuridae/flatbuffers that referenced this issue Dec 12, 2024
Fixes access to union members when generating code with options "--cpp-field-case-style upper" and "--gen-object-api"
Ailuridae added a commit to Ailuridae/flatbuffers that referenced this issue Dec 12, 2024
Fixes access to union members when generating code with options "--cpp-field-case-style upper" and "--gen-object-api"
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

1 participant