From 47361baf61d635e65346d796c609d534e65d20d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Dziwi=C5=84ski?= Date: Fri, 7 May 2021 09:42:44 +1200 Subject: [PATCH] [C++] Fix union copy constructor to work with nested structs (#6552) (#6607) --- src/idl_gen_cpp.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/idl_gen_cpp.cpp b/src/idl_gen_cpp.cpp index f80af0459..210a38f7a 100644 --- 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();