From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44510) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zgun6-0006Pg-49 for qemu-devel@nongnu.org; Tue, 29 Sep 2015 09:17:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zgun0-0004e2-Ba for qemu-devel@nongnu.org; Tue, 29 Sep 2015 09:17:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32824) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zgun0-0004dw-6J for qemu-devel@nongnu.org; Tue, 29 Sep 2015 09:17:50 -0400 From: Markus Armbruster References: <1443497249-15361-1-git-send-email-eblake@redhat.com> <1443497249-15361-8-git-send-email-eblake@redhat.com> Date: Tue, 29 Sep 2015 15:17:47 +0200 In-Reply-To: <1443497249-15361-8-git-send-email-eblake@redhat.com> (Eric Blake's message of "Mon, 28 Sep 2015 21:27:20 -0600") Message-ID: <87wpv9icuc.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v6 07/16] qapi: Add tests for empty unions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: marcandre.lureau@redhat.com, qemu-devel@nongnu.org, ehabkost@redhat.com, Michael Roth Eric Blake writes: > The documentation claims that alternates are useful for > allowing two types, although nothing enforces this. Meanwhile, "two or more" Can touch up on commit. > it is silent on whether empty unions are allowed. In practice, > the generated code will compile, in part because we have a > 'void *data' branch; but attempting to visit such a type will > cause an abort(). While there's no technical reason that a > degenerate union could not be made to work, it's harder to > justify the time spent in chasing known (the current abort() > during visit) and unknown corner cases, than it would be to > just outlaw them. A future patch will probably take the > approach of forbidding them; in the meantime, we can at least > add testsuite coverage to make it obvious where things stand. > > In addition to adding tests to expose the problems, we also > need to adjust existing tests that are meant to test something > else, but which could fail for the wrong reason if we reject > degenerate alternates/unions. > > Note that empty structs are explicitly supported (for example, > right now they are the only way to specify that one branch of a > flat union adds no additional members), and empty enums are > covered by the testsuite as working (even if they do not seem > to have much use). > > Signed-off-by: Eric Blake > > --- > v6: commit message improved, rebase to earlier added tests Patch is fine.