Skip to content

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

@Ailuridae

Description

@Ailuridae

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

// ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions