Received: from eggs.gnu.org ([2001:4830:134:3::10]:45593) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZJych-0003cx-Ne for qemu-devel@nongnu.org; Tue, 28 Jul 2015 02:44:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZJycd-0005RZ-DK for qemu-devel@nongnu.org; Tue, 28 Jul 2015 02:44:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47260) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZJycd-0005RK-8D for qemu-devel@nongnu.org; Tue, 28 Jul 2015 02:44:19 -0400 From: Markus Armbruster References: <1435782155-31412-1-git-send-email-armbru@redhat.com> <1435782155-31412-28-git-send-email-armbru@redhat.com> <55B6A40A.8070400@redhat.com> Date: Tue, 28 Jul 2015 08:44:16 +0200 In-Reply-To: <55B6A40A.8070400@redhat.com> (Eric Blake's message of "Mon, 27 Jul 2015 15:35:06 -0600") Message-ID: <874mkopyrj.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH RFC v2 27/47] qapi-visit: Convert to QAPISchemaVisitor, fixing bugs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: kwolf@redhat.com, berto@igalia.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com Eric Blake writes: > On 07/01/2015 02:22 PM, Markus Armbruster wrote: >> Fixes flat unions to visit the base's base members (the previous >> commit merely added them to the struct). Same test case. >> >> Patch's effect on visit_type_UserDefFlatUnion(): >> >> static void visit_type_UserDefFlatUnion_fields(Visitor *m, UserDefFlatUnion **obj, Error **errp) >> { >> Error *err = NULL; >> >> + visit_type_int(m, &(*obj)->integer, "integer", &err); >> + if (err) { >> + goto out; >> + } >> visit_type_str(m, &(*obj)->string, "string", &err); >> if (err) { >> goto out; >> > >> +def gen_visit_union(name, base, variants): >> + ret = '' >> >> if base: >> - assert discriminator >> - base_fields = find_struct(base)['data'].copy() >> - del base_fields[discriminator] >> - ret += generate_visit_struct_fields(name, base_fields) >> + members = [m for m in base.members if m != variants.tag_member] >> + ret += generate_visit_struct_fields(name, members) > > Ouch. This hurts. If the same class is used as both the base class of a > flat union, and the base class of an ordinary struct, then the struct > tries to visit the base class, but no longer parses the field that the > union was using as its discriminator. > > We don't have any code that demonstrates this, but probably should. I > ran into it while working up my POC of what it would take to unbox > inherited structs (http://thread.gmane.org/gmane.comp.emulators.qemu/353204) Is this broken in master, or do my patches break it? Got a reproducer? [...]