Skip to content

--cpp-ptr-type naked is broken for array members. #8790

@sgh

Description

@sgh

This schema bellow renerated wrong code when compiled with this flatc command.

flatc --cpp-ptr-type naked --cpp-std=c++17 --reflect-types --reflect-names --cpp-static-reflection --gen-object-api --cpp

table B {
id: int32;
}

table A {
b: [B];
}

ploef_generated.h: In member function »void A::UnPackTo(AT*, const flatbuffers::resolver_function_t*) const«: ploef_generated.h:834:167: fejl: request for member »get« in »_o->AT::b.std::vector<BT*>::operator[](((std::vector<BT*>::size_type)_i))«, which is of pointer type »__gnu_cxx::__alloc_traits<std::allocator<BT*>, BT*>::value_type« {aka »BT*«} (maybe you meant to use »->« ?) 834 | tbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->b[_i]) { _e->Get(_i)->UnPackTo(_o->b[_i].get(), _resolver); } else { _o->b[_i] = (_e->Get(_i)->UnPack(_resolver)); } } } else { _o->b.resize(0); } }

If B is a struct to problem goes away.

Metadata

Metadata

Assignees

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