projects
/
platform
/
upstream
/
flatbuffers.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
8a58288
)
[C++] Fix union copy constructor to work with nested structs (#6552) (#6607)
author
Piotr Dziwiński
<piotrdz@gmail.com>
Thu, 6 May 2021 21:42:44 +0000
(09:42 +1200)
committer
GitHub
<noreply@github.com>
Thu, 6 May 2021 21:42:44 +0000
(14:42 -0700)
src/idl_gen_cpp.cpp
patch
|
blob
|
history
diff --git
a/src/idl_gen_cpp.cpp
b/src/idl_gen_cpp.cpp
index
f80af04
..
210a38f
100644
(file)
--- a/
src/idl_gen_cpp.cpp
+++ b/
src/idl_gen_cpp.cpp
@@
-1534,7
+1534,8
@@
class CppGenerator : public BaseGenerator {
code_.SetValue("TYPE", GetUnionElement(ev, true, opts_));
code_ += " case {{LABEL}}: {";
bool copyable = true;
- if (ev.union_type.base_type == BASE_TYPE_STRUCT) {
+ if (ev.union_type.base_type == BASE_TYPE_STRUCT &&
+ !ev.union_type.struct_def->fixed) {
// Don't generate code to copy if table is not copyable.
// TODO(wvo): make tables copyable instead.
for (auto fit = ev.union_type.struct_def->fields.vec.begin();