On 11/10/2015 11:51 PM, Eric Blake wrote: > Previously, working with alternates required two lookup arrays > and some indirection: for type Foo, we created Foo_qtypes[] > which maps each qtype to a value of the generated FooKind enum, > then look up that value in FooKind_lookup[] like we do for other > union types. > > This has a couple of subtle bugs. First, the generator was > creating a call with a parameter '(int *) &(*obj)->type' where > type is an enum type; this is unsafe if the compiler chooses > to store the enum type in a different size than int, where > assigning through the wrong size pointer can corrupt data or > cause a SIGBUS. Yuck - we still have this bug for enums: > void visit_type_OnOffAuto(Visitor *v, OnOffAuto *obj, const char *name, Error **errp) > { > visit_type_enum(v, (int *)obj, OnOffAuto_lookup, "OnOffAuto", name, errp); > } I guess I just added more work to my plate. But at the same time, no one has complained of the (int*)Enum causing SIGBUS on any of our platforms for either enums or alternates, so while we are doing gross things, I don't think we have to rush a fix into 2.5 for this particular bug. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org